Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check to see if exe is already running.
Message
De
20/08/1997 16:22:14
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00045900
Message ID:
00045957
Vues:
24
>I have written an app in VFP5.0a I need to find a way to check if my app is already running when a user starts it. If the app is already running I then need to move focus to the one previously started.
>
>any help in this matter will be greatly appreciated.

Craig,

Try putting this code in your MAIN.PRG. It won't move focus to the active instance but it will keep users from starting your app 20 times!

Notice that when you create the .app file, you'll get the message "RegFn not found" and "CallFn not found". I just ignore these and it works fine.


*********************************************************************
* only start if not already running
SET LIBRARY TO SYS(2004)+"foxtools.fll" ADDITIVE

* FindWindow() takes two parameters and returns the handle of the window, HWND, if it was found.
GetWind = RegFn("FindWindow", "CC", "I")

* Set the first parameter of the call to getwind to 0, null.
wclass=0
winname="MY APPLICATION"
apphand=CallFn(GetWind,wclass ,winname)

* If the call was successful, stop processing.
IF apphand<>0
WAIT WINDOW "The program is already running."
QUIT
ELSE
MODIFY WINDOW SCREEN TITLE winname
.
.
.
* start your system
.
.
.
ENDIF
*********************************************************************
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform