Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking to see if a program is running
Message
 
 
À
04/12/2002 11:53:53
Todd Wolfe
Certified Marketing Services
Kinderhook, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00729488
Message ID:
00729491
Vues:
33
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform