>Çetin,
>
>I saw this thread and I would like to put the AppAlreadyRunning() into my app as well, but could you give a brief explaination on what the code is doing, because I will have to support this and I would like to know how it works.
It tries to create a semaphore (unoffically you could think of it as a slot) with a unique name. If that semaphore was created before (and still active) function returns a handle to the existing one and GetLastError() return ERROR_ALREADY_EXISTS as an error and that's just we want.
It works very well for me. ie: Suppose I tried to test my app in IDE environment and ran my main.prg there. If I then try to run the exe version while VFP still up I can't :) Semaphore is created for my IDE session. IOW it's free from window captions, handles etc.
You might use CreateMutext instead in the same manner. I really don't have an idea what was I thinking when I did it and used CreateSemaphore instead :) Since it worked nice for years I didn't touch again.
PS: Key point is to use a good unique name for your semaphore. Than it doesn't matter what the application name is, wcaption is etc.
ie: MyApp is a bad name :)
JohnHusseyApps_AccountingManagerV1.0.1
is a good name - if you want multiple version builts to run simultaneously and not hardcoded version part:)
Cetin