Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One Instance
Message
De
04/11/2004 09:40:14
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
04/11/2004 00:51:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00957965
Message ID:
00958074
Vues:
17
>Hi All,
>
>How would I write code(s) to allow only one instance of the application to be executed? (check and prevent execution) Any suggestions or ideas is very appreciated.
>
>TIA
* Entr
if IsAppRunning(Application.ServerName) && or any unique string you want - ie: MyNiceApplication
*...
endif

Function IsAppRunning
	Lparameters tcSemaphoreName
	Local hsem, lpszSemName
	#Define ERROR_ALREADY_EXISTS 183
	Declare Integer GetLastError In win32API
	Declare Integer CreateSemaphore In WIN32API ;
		string @ lpSemaphoreAttributes, ;
		LONG lInitialCount, ;
		LONG lMaximumCount, ;
		string @ lpName
	hsem = CreateSemaphore(0,0,1,tcSemaphoreName)
	Return (hsem # 0 And GetLastError() == ERROR_ALREADY_EXISTS)
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