Does anyone know how I can find the property for % processor usage. I have looked through the docs on the WMI control and can not find a single EXE % processor usage. I know their is a control written in VB that will give me the information, but I want to get the information through the WMI and VFP only.
>
>Thanks,
>Dale
Hi Dale,
Here is a set of
WMI utilities, one of which is a WMI Object Browser.
Have you looked on MSDN, there's quite a bit on WMI:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_reference.asp?frame=truehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/performance_counter_classes.aspI also found this example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.aspWhich I believe translates to:
objService = GetObject("Winmgmts:{impersonationlevel=impersonate}!\Root\Cimv2")
For i = 1 to 8
objInstance1 = objService.Get("Win32_PerfRawData_PerfOS_Processor.Name='_Total'")
N1 = Val(objInstance1.PercentProcessorTime)
D1 = Val(objInstance1.TimeStamp_Sys100NS)
declare Sleep in Win32API integer nMilliseconds
=Sleep(2000)
perf_instance2 = objService.get("Win32_PerfRawData_PerfOS_Processor.Name='_Total'")
N2 = Val(perf_instance2.PercentProcessorTime)
D2 = Val(perf_instance2.TimeStamp_Sys100NS)
PercentProcessorTime = (1 - ((N2 - N1)/(D2-D1)))*100
?"% Processor Time=" , Round(PercentProcessorTime,2)
Next
Regards,
- Brian
VFP6 SP5, VFP8 SP1, VFP 9 SP 1 and Win XP SP 3 (unless otherwise specified)
www.wulfsden.com