以下代码用于访问Win32处理器信息....
是否有任何其他方式来获取win32处理器信息(如使用不同的类)。这里我使用了课程WqlObjectQuery
和ManagementObjectSearcher
。
WqlObjectQuery wquery = new WqlObjectQuery("select * from Win32_Processor");
ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(wquery);
foreach (ManagementObject mo1 in searcher1.Get())
{
Console.WriteLine(mo1.ToString());
}
我们可以使用任何其他类来获取win32处理器的属性
答案 0 :(得分:3)
获取当前处理器名称在计算机上运行
查看WMI资源管理器,这是使用WMI Query Tool
的一个非常好的工具ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_Processor")
foreach (ManagementObject mo in mos.Get())
{
Console.WriteLine(mo["Name"]);
}
//获取姓名,制造商,计算机名称等......
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());
}
答案 1 :(得分:1)