Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to detect of Winmgmt is installed
Message
De
20/06/2005 16:46:11
Bill Drew
Independent Consultant
Chicago, Illinois, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
01024909
Message ID:
01024951
Vues:
15
Thanks Sergey,

I have to compile this in Version 7. So it looks like I have to add it handle it with ON ERROR rather than TRY CATCH. If you know of any other way, let me know.
Bill

>Hi Bill,
>
>Would this work for you?
>TRY
>	loCheckWMIService = Getobject("winmgmts:")
>CATCH TO oExp WHEN oExp.Errorno = 1426
>	* WMI is not installed
>ENDTRY	
>
>>I am trying to make sure that a second instance of the program is not running when a user starts. With one installation, we are getting the error Library Not Registered. I was assuming that I could count on it being available with Win ME and above. But I need to make a tighter check.
>>
>>
>>The code is
>>IF "WINDOWS 5." $ UPPER(OS(1)) OR "WINDOWS 4.9" $ UPPER(OS(1))
>>	IF HmProcessRunning("QPLAUNCH.EXE") > 1
>>		MESSAGEBOX("QPLAUNCHER IS ALREADY RUNNING",0,"CANNOT START")
>>		DO SHUTITDOWN
>>	ENDIF
>>ELSE
>>	IF IsWindEx2("QuotePro Launcher")
>>		DO SHUTITDOWN
>>	ENDIF
>>ENDI
>>
>>****************************
>>FUNCTION HmProcessRunning
>>****************************
>>LPARAMETERS PROCESS2CHECK
>>PRIVATE nRetVal
>>nRetVal = 0
>>lcComputer = '.'
>>loWMIService = Getobject('winmgmts:'+ '{impersonationLevel=impersonate}!\\' + ;
>lcComputer + '\root\cimv2')
>>colProcessList = loWMIService.ExecQuery ('Select * from Win32_Process')
>>For Each loProcess In colProcessList
>>	IF UPPER(loProcess.Name) = UPPER(process2check)
>>		nRetVal = nRetVal + 1
>>	ENDIF
>>ENDF
>>RETURN nRetVal
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform