TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Francois Thunus
from: Phil Crown
date: 1996-06-20 13:11:58
subject: semaphore

-=> Quoting David Noon to Francois Thunus <=- 

 DN> On Sunday, 96/06/16, Francois Thunus wrote to All about "semaphore"
 DN> as follows:
 
 FT> I don't want 2 copies of my program to run at the same time.
 FT> I use DosCreateMutEx to create a semaphore when starting 
 FT> the program, and DosDeleteMutEx when I'm done. or do I ?. 

There is another way to check if a PM app is running.  This is from the
OS/2 Programmers FAQ, PFAQ3x.ZIP, but I modified it a little and put it
in a dll.

// --------------------------------------------------------------------
MRESULT EXPENTRY  QueryAppInstance(PCHAR pchClassWanted)
{
  HENUM heEnum;
  HWND  hwndTop;
  HWND  hwndClient;
  CHAR  achClass[256];

  heEnum=WinBeginEnumWindows(HWND_DESKTOP);
  hwndTop=WinGetNextWindow(heEnum);
  while(hwndTop!=NULLHANDLE) {
    hwndClient=WinWindowFromID(hwndTop,FID_CLIENT);
    if(hwndClient!=NULLHANDLE) {
      WinQueryClassName(hwndClient,sizeof(achClass),achClass);
      if(strcmp(achClass,pchClassWanted)==0) {
        WinEndEnumWindows(heEnum);
        return (MRESULT) hwndClient;
      }
    }
    hwndTop=WinGetNextWindow(heEnum);
  }
  WinEndEnumWindows(heEnum);
  return (MRESULT) NULLHANDLE;
}

Phil - Fido:  1:124/8014.0 | Internet:  phil.crown{at}bluecafe.com

--- Blue Wave/OS2 v2.30
* Origin: * MacSavvy OS/2 BBS * Dallas, Texas * 214-250-4479 * (1:124/1208)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 517 628 713/888 800/1
@PATH: 124/1208 1 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.