You can monitor, and manage system devices using System.Management namespace using Windows Management Instrumentation (WMI). Here I give you an example for to retrieving all processors and display their names, current speed and maximum speed. At first a ManagementObjectSearcher object has been created by passing the WQL query string to its constructor. WQL (Windows Query Language) is a subset of SQL (Structured Query Language) and specifically designed for WMI. The query string "SELECT * FROM Win32_Processor" returns any 32 – bit processors available. The Get method returns ManagementObject collection which you can go through all retrieved processors using foreach.
static void
{
ManagementObjectSearcher Processors = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
foreach (
Console.WriteLine("Name :{0}, Current Clock Speed: {1}, Maximum Clock Speed: {2}", Mo["Name"], Mo["CurrentClockSpeed"], Mo["MaxClockSpeed"]);
Console.ReadLine();
}
Running the above code we can get available processor’s names, current speed and maximum speed.
No comments:
Post a Comment