Reputation: 945
the following code is used to access the Win32 processor information....
is there is any other way for getting the win32 processor information (like using different classes). here i have used the class WqlObjectQuery
and ManagementObjectSearcher
.
WqlObjectQuery wquery = new WqlObjectQuery("select * from Win32_Processor");
ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(wquery);
foreach (ManagementObject mo1 in searcher1.Get())
{
Console.WriteLine(mo1.ToString());
}
can we use any other classes to get the properties of win32 processor
Upvotes: 1
Views: 6746
Reputation: 1627
yes it is definitely possible to get the hardware as well as software using WMI...there is a tool provided by microsoft to navigate the WMI classes and functions. The tool is Windows management Instrumentation tester. it can be opened by typing wbemtest in command prompt. You can experiment using the tool. Moreover you can check this Link and this link, and trying doing some research from your side.
Apart from all this you can use the query as "select * from Win32_Processor where DeviceID=CPU0" as you want to get the information about single processor
Upvotes: 1
Reputation: 18863
Get the Current Processor name running on the Machine
Checkout the WMI Explorer as well it's a really good tool to use WMI Query Tool
ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Processor")
foreach (ManagementObject mo in mos.Get())
{
Console.WriteLine(mo["Name"]);
}
//Get Name , Manufacturer, Computer Name, etc...
ManagementObjectSearcher mosQuery = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection queryCollection1 = mosQuery.Get();
foreach (ManagementObject manObject in queryCollection1)
{
Console.WriteLine("Name : " + manObject["name"].ToString());
Console.WriteLine("Version : " + manObject["version"].ToString());
Console.WriteLine("Manufacturer : " + manObject["Manufacturer"].ToString());
Console.WriteLine("Computer Name : " + manObject["csname"].ToString());
Console.WriteLine("Windows Directory : " + manObject["WindowsDirectory"].ToString());
}
Upvotes: 3