Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

find out how processor load using wmi

, 25 Sep 2009
Rate this:
Please Sign up or sign in to vote.
Example of how to find out the processor load using wmi (windows management instrument)

Sample Image - maximum width is 600 pixels

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.

Sample Image - maximum width is 600 pixels

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

Sample Image - maximum width is 600 pixels

space used name: using System.Management;
reference: System.Management.DLL

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

jesuli
Software Developer
Spain Spain
No Biography provided

Comments and Discussions

 
GeneralExactly what i was looking for! PinmemberMatheusMK325-Jan-10 7:52 
GeneralMy vote of 1 PinmemberHotcut27-Sep-09 21:49 
GeneralRe: My vote of 1 Pinmemberjesuli28-Sep-09 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 25 Sep 2009
Article Copyright 2009 by jesuli
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid