>Hi George,
>
>I finnaly got a chance to try out the code from the article. I have a question. In the INIT procedure of the MUTEX the line:
>.nmutexerror = getlasterror() always gives me 0.
>
>Since I had no idea what a MUTEX was and didn't have Win32.hlp, I created a .prg called MUTEX.prg. In it I put:
>
>DEFINE CLASS mutex AS CUSTOM
>
> cformcaption = ""
> hmutex = 1
> nmutexerror = 0
>
>Then I put the 3 procedures.
>
>Since I never created a class other than an object class I could use on a form I assumed this was the correct way to get this going.
>
>Any insights you have would be much apreciated
>
>TIA
Mike,
The article pretty much answers all of your questions, but to re-cap...When the class initantiates, it attempts to create a mutex object. These are named objects, which are global within Windows. The code uses the caption of the _SCREEN or in the case of an SDI application form to name the mutex. GetLastError() will return a value other than zero if an error occurred in attempting to create the mutex. Mutex comes from the term "
Mutually
Exclusive". Any progam can access it, but only one can own it, namely, the program that created it. In this case, if the particular mutex already exists, GetLastError() will return ERROR_ALREADY_EXISTS (183), that's the indication that an instance of the program is already running. By checking the value of nMutexError after initializing the object, you know this and can act accordingly.
George
Ubi caritas et amor, deus ibi est