Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check if an application is already running ?
Message
De
08/04/2004 04:48:58
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
08/04/2004 04:27:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00891439
Message ID:
00893206
Vues:
22
>Ç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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform