Introduction
Example of how to find out the processor load using wmi (windows management instrument)
WMI is an administrative tool included with the windows systems. For administrators
with WMI access to all information of a pc, such as memory, hard disk, network card, processor, short quite easily without programming in Assembly to gain access to this information can be...
for more information about WMI can go to this address
http://technet2.microsoft.com/WindowsServer/es/Library/cc37ec96-9bd0-4c6a-8e5a-5805563a61b73082.mspx?mfr=true
Using the Code
To determine the processor load we must creates an instance of WMI and so use the member functions of object.
To create a WMI instacia be follows.
ManagementObject processor = new ManagementObject();
ManagementObject has several overloaded, constructore with miscellaneous parameter, in our case, we'll use in type string constructor and passing data you wish to have access to information, telling that we want to have the burden of processor and system information. In this way
ManagementObject processor = new ManagementObject( "Win32_PerfFormattedData_PerfOS_Processor.Name='_Total'")
Win32_PerfFormattedData_PerfOS_Processor. It is a responsible for WMI classes of da charging system on the processor, through its Name property condition information passing finds it _Total we want the total value of the system overhead.
A view that we see a ManagementObject instance created will use the Get method of the ManagementObject classes for associated instance object created in this way
processor.Get();
in this way we can already calls to the method and properties in classes, in this case call the object properties that it will not return the value of the properties of the query object properties here will not return the percentage of processor time
processor.Properties["PercentProcessorTime"].Value;
to summarize all do so
ManagementObject processor = new ManagementObject(
"Win32_PerfFormattedData_PerfOS_Processor.Name='_Total'");
processor.Get();
processor.Properties["PercentProcessorTime"].Value;
as ye see the code short compared if we had used Assembly low-level by directly calling the bios is
to continuation or I will leave the code strong example as shown in this shot.
the code you can modify or distribute it only to do mensio author this program set yourselves in the following image is fine-tuning the code and them is converted into a sensor
space used name: using System.Management;
reference: System.Management.DLL
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.