Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Tell If An Application Is Running
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2000 Server
Miscellaneous
Thread ID:
01309824
Message ID:
01309833
Views:
10
>How can you tell what applications are running or what windows are present?
OK Here what I'm used:
*** In My Main program
PRIVATE lnHref
IF __IsRunning([SomeUniqueNameOrSomething])
   MessagerBox([Program already is in use])
   RETURN .f.
ENDIF

*** In my clearing (shutdown program, or error routine or whenever I quoit the application):
 DECLARE CloseHandle IN WIN32API LONG hHandle
CloseHandle(lnHref)






FUNCTION __IsRunning(tcSemaphoreName)
     LOCAL lbReturnValue
     Declare Integer GetLastError In win32API

     Declare Integer CreateSemaphore In WIN32API ;
                                        string @ lpSemaphoreAttributes, ;
                                        LONG lInitialCount, ;
                                        LONG lMaximumCount, ;
                                        string @ lpName
     lnHref          = CreateSemaphore(0,0,1,UPPER(tcSemaphoreName))
     m.lbReturnValue = (lnHref # 0 .AND. GetLastError() == ERROR_ALREADY_EXISTS)

RETURN m.lbReturnValue
But you should check for MUTEX because they give you more flexibility.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform