Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking to see if a program is running
Message
 
 
To
04/12/2002 11:53:53
Todd Wolfe
Certified Marketing Services
Kinderhook, New York, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00729488
Message ID:
00729491
Views:
32
>How can Fox Pro be used to tell if another application is already running or not?

From Russian VFP Club Forum by Vitaliy:
Function ProcessIsRun 
Lparameters lcProcName 

Declare INTEGER CreateToolhelp32Snapshot IN Win32api INTEGER dwFlags, INTEGER th32ProcessID 
Declare INTEGER Process32First IN Win32api INTEGER lhSnapshot, STRING lppe 
Declare INTEGER Process32Next IN Win32api INTEGER lhSnapshot, STRING lppe 
Declare INTEGER CloseHandle IN kernel32 INTEGER hObject 

Local lnRetCode, lppe, lhSnapshot 

lcProcName = UPPER(lcProcName) 
lppe = CHR(44) + CHR(1) + REPLICATE(CHR(0), 298) 

lhSnapshot = CreateToolhelp32Snapshot(2, 0) 
lnRetCode = Process32First(lhSnapshot, @lppe) 

Do WHILE lnRetCode <> 0 
 If lcProcName $ UPPER(SUBSTR(lppe, 37, 256)) 
   lnRetCode = 1 
   Exit 
 Endif 
lnRetCode = Process32Next(lhSnapshot, @lppe) 
Enddo 

CloseHandle(lhSnapshot) 

Return lnRetCode
?ProcessIsRun('vfp') - 1
?ProcessIsRun('ie') - 1
?ProcessIsRun('word') - 0 && Word is not running
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform