Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WMI control
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00803110
Message ID:
00803123
Views:
10
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=true

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/performance_counter_classes.asp

I also found this example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp

Which 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)

  *Sleep for two seconds = 2000 ms
   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)

   * CounterType - PERF_100NSEC_TIMER_INV
   * Formula - (1- ((N2 - N1) / (D2 - D1))) x 100

   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
Previous
Reply
Map
View

Click here to load this message in the networking platform