>>Hi Nadya,
>>
>>The API you reference to only shows how to prevent second instance of the application from running. The "FirstInstance.prg" does the same in vary similar way. In addition it shows how to make already open application's window active.
>
>Sergey,
>
>Having written the article and having seen Ed's code, if I were currently looking for a solution to this problem, I'd probably use Ed's method with the necessary additions to display the original instance of the application. I say this because Ed's solution requires less code overhead, and, therefore, would be easier to maintain.
>
>Admittedly, I still use my solution, but only because it's the method recommended in the Platform SDK.
Hi George,
Maybe I'm missing something, but only difference I see in Ed's code that it creates event instead of mutex.
DECLARE INTEGER CreateEvent IN WIN32API ;
INTEGER lpEventAttributes, ;
SHORT bManualReset, ;
SHORT bInitialState, ;
STRING @ lpName
DECLARE INTEGER GetLastError IN Win32API
DECLARE CloseHandle IN Win32API INTEGER hObject
nEh = CreateEvent(0,0,1, PROGRAM(0) + '.EVENT')
IF GetLastError() = ...
DECLARE INTEGER CreateMutex IN win32api INTEGER, INTEGER, STRING @
DECLARE INTEGER GetLastError IN Win32API
DECLARE CloseHandle IN Win32API INTEGER hObject
cExeFlag = "STARBASE"+CHR(0)
nExeHwnd = CreateMutex(0,1,@cExeFlag)
IF GetLastError() = ...
As I can see both of them use the same amount of code.
--sb--