Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Application is running
Message
 
 
To
19/07/2001 11:05:33
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00532587
Message ID:
00532743
Views:
10
>I'm trying to find a way to be sure that only one instance of my foxpro application is running. So when i start the application a second time, i want to show the user a message.
>
>Ok I know there is an api call witch compares the captions of running application, but I don't whant to use that because an other application or a mail message can have the same caption.
>
>Thanks.
>
>Gerben.

My colleague implemented the following code:
* -- NSL 6/6/01  Check to see if there are other copies of JC instanciated
*--------------------------------------------------------------------------
PRIVATE lcLibrary,GetWind
lcLibrary=SET('LIBRARY')
SET LIBRARY TO sys(2004)+"foxtools.fll" ADDITIVE
GetWind=RegFn("FindWindow","CC","I")
wclass=0  
winName=Left(_screen.caption,len(_screen.caption)-1)  && Trim off the colon  - findwindow did not like that.
apphand=CallFn(GetWind,wclass,winName)

IF apphand<>0
	=mymessage('There is already a version of job control running from this machine.'+chr(13)+;
			'Only one version of JC can be running at a time.')
	close all
	clear all
	on error
*!*		if type('cOldScreenCaption')='C'
*!*	 		 _screen.caption=cOldScreenCaption
*!*		endif  
	clear events
	clear
	set sysmenu to default
	* Exit out of VFP
	RETURN
ENDIF
Modify Window screen TITLE winName
SET LIBRARY TO &lcLibrary
But I would not recommend it. Check API section here for the Ed Rauh's CreateEvent example.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform