Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CPU Status
Message
De
08/09/2006 09:22:47
 
 
À
08/09/2006 09:01:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01152193
Message ID:
01152240
Vues:
17
Hi Stuart!
Cool! .. is there exist a WMI Query to ask about process CPU utilization? For example, to get an information about my application process only.

Thanks a lot!
Denis

>Hi
>
>You can use WMI, as long as you don't have to support Windows 9x clients (as the class used was introduced in Windows 2000). If you need to interrogate multiple processors then change the Name property in the query to 1,2,3 etc.
>
>
>declare Sleep in WIN32API integer
>
>oWMIService = getobject("winmgmts:\\")
>oItems = oWMIService.ExecQuery ;
>	("Select * From Win32_PerfRawData_PerfOS_Processor where name = '0'")
>for each oItem in oItems
>	nPercentUsed1 = val(oItem.PercentUserTime)
>	nTimeValue1 = val(oItem.TimeStamp_Sys100NS)
>next
>
>* Take five snapshots 100 milliseconds apart
>* to get a truer idea of processor usage
>for nCounter = 1 to 5
>	Sleep(100)
>	oItems = oWMIService.ExecQuery ;
>		("Select * From Win32_PerfRawData_PerfOS_Processor where name = '0'")
>		
>	for each oItem in oItems
>		nPercentUsed2 = val(oItem.PercentUserTime)
>		nTimeValue2 = val(oItem.TimeStamp_Sys100NS)
>
>		if nTimeValue2 - nTimeValue1 = 0
>			nPercentProcessorTime = 0
>		else
>			nPercentProcessorTime = 100 * (nPercentUsed2 - nPercentUsed1) / ;
>				(nTimeValue2 - nTimeValue1)
>			? transform(nPercentProcessorTime) + "% used"
>		endif
>		nPercentUsed1 = nPercentUsed2
>		nTimeValue1 = nTimeValue2
>	next
>next
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform