Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CPU Status
Message
From
08/09/2006 09:22:47
 
 
To
08/09/2006 09:01:52
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01152193
Message ID:
01152240
Views:
16
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
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform