Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting ProcessID of currently running program
Message
 
À
03/08/2009 11:34:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
Visual FoxPro
Divers
Thread ID:
01415896
Message ID:
01415911
Vues:
61
Here's code that will check to see if your application is already running:
LPARAMETERS lcWindowName,lcSimpleAppName

** check to see if app is already open
DECLARE INTEGER FindWindow IN Win32API STRING lpClassName, STRING lpWindowName
DECLARE INTEGER IsIconic IN Win32api INTEGER
DECLARE ShowWindow IN Win32api INTEGER,INTEGER
DECLARE SetForegroundWindow IN Win32api INTEGER

nWinHandle = FindWindow(.NULL., lcWindowName)

*Returns 0 if it can't find "YourApp" as a window title,
*otherwise it returns a handle > 0
IF nWinHandle <> 0
	llFound=.T.
	MESSAGEBOX('A current session of '+ALLTRIM(lcSimpleAppName)+' is already in use.'+CHR(13)+CHR(10)+;
				'Only one session of '+ALLTRIM(lcSimpleAppName)+' can be used at a time.',0+64+0,_screen.Caption)
	IF IsIconic(nWinHandle) = 1
		ShowWindow(nWinHandle,4)
	ENDIF
	*Wait Wind "App is already running."+ CHR(13) + ;
	* "Switching to establish session." Timeout 2
	SetForegroundWindow(nWinHandle)
	QUIT
ENDIF
Brandon Harker
Sebae Data Solutions
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform