Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding another instance of a VFP app running
Message
 
To
30/04/2001 13:21:56
Isabel Cabanne
Hubbard Woods Software, Inc.
Winnetka, Illinois, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00501647
Message ID:
00502198
Views:
21
This is old code and can be done without foxtools now but here is what I have been using. I haven't bothered to rewrite it yet just declaring my function in the api.

You will have to modify it slightly to work for you as there are some public vars in here that were defined in another part of the program.

Hope this helps.

Tommy
PARAMETER winname
PRIVATE pnlibrary, pcmessage
pnlibrary = SET("LIBRARY")
SET LIBRARY TO gcroot+"\FOXTOOLS.fll"
* FindWindow() takes two parameters and returns the handle of the window, HWND, if it was found.
GetWind = RegFn("FindWindow", "CC", "I")
wclass=0			&&Set the first parameter of the call to getwind to 0, null.
apphand=CallFn(GetWind,wclass ,winname)
IF apphand<>0	&& If the call was successful, stop processing.
	pcmessage = ALLTRIM(g_appname) + CHR(13) + " Is already running on this computer!"
	WAIT WINDOW TIMEOUT 10 pcmessage
        *deal with an exit here
ENDIF
SET LIBRARY TO &pnlibrary
Tommy

>I would like to prevent users from opening multiple instances of an application, ideally by switching them to the open app, but at least giving a message and not opening the second instance.
>
>How can I detect that another instance of a VFP app is running? Also, is there some way to switch the user automatically to the open instance?
>
>Thanks,
>Isabel
Previous
Reply
Map
View

Click here to load this message in the networking platform