Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Instance
Message
From
04/11/2004 09:40:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/11/2004 00:51:36
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00957965
Message ID:
00958074
Views:
16
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform