Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to tell if another is running
Message
 
À
27/04/2004 09:14:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00898482
Message ID:
00898646
Vues:
43
>This question has probably been asked a thousand times, how can I tell if an app is already running. i.e. GroupWise or MS Word etc etc...

John, you can use WMI for this:
lparameters tcComputer, tcProcess
local lcComputer, loWMIService, loProcess, loProcesses, lcProcess

lcComputer			= Iif(Vartype(tcComputer) = 'C' and not Empty(tcComputer), tcComputer, '.')
lcProcess			= Iif(Vartype(tcProcess) = 'C', tcProcess, '')
loWMIService		= GetObject("winmgmts://" + lcComputer + "/root/cimv2")
loProcesses			= loWMIService.ExecQuery("SELECT * FROM Win32_Process" + Iif(Empty(lcProcess), "", " Where Name = '" + lcProcess + "'"))
clear
For Each loProcess in loProcesses
	with loProcess
		? .Name, .ExecutablePath, .caption, .commandline, Ctot(Transform(.CreationDate, '@R 9999-99-99T99:99:9999'))
	endwith
Next
For example if you want to know if VFP8.EXE is running, you call
do with '.', 'Vfp8.EXE'
Where '.' is the local computer, you can remove this parameter alltogether, because you'll need to have rights on the remote computer to run WMI
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform