Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Know if a program is already running
Message
From
20/06/2003 07:52:01
 
 
To
20/06/2003 06:57:39
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00802126
Message ID:
00802137
Views:
26
How can I know if my application is
already running when I started it?
FUNCTION OnceOnly
LOCAL lnHWND, lcTitle, llRetVal

*** Set UP API Calls
Declare Integer FindWindow IN Win32Api AS FindApp String, String
Declare BringWindowToTop   IN Win32APi AS MakeTop Integer
Declare ShowWindow         IN Win32Api AS ShowWin Integer, Integer
    
*** Get the current Screen Caption
lcTitle = _Screen.Caption

*** Change it to avoid finding the current instance
_Screen.Caption = SYS(3)

*** Now locate another instance
lnHWND = FindApp( NULL, lcTitle )

*** And restore the original caption
_Screen.Caption = lcTitle

*** Check the results
IF lnHWND > 0
  *** We have found something!
  *** So make it uppermost and maximize it (ShowWin => 3)
  MakeTop( lnHWND )
  ShowWin( lnHWND, 3 )
  *** Set the Return Value
  llRetVal = .T.
ENDIF

*** Return Status for action
RETURN llRetVal
Previous
Reply
Map
View

Click here to load this message in the networking platform