我试图使用 WMI 获取一些系统信息,
但问题是当我想获取例如图形卡信息时.. 我有很多驱动程序(真实和虚拟)
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select Name from " + key);
foreach (ManagementObject share in searcher.Get())
{
Console.WriteLine(share["Name"].ToString());
}
结果是:
Radmin Mirror Driver v3
ATI Mobility Radeon HD 5650
LogMeIn Mirror Driver
PCI GDIHOOK5
所以我决定编辑查询以仅获取真实的查询。在这种情况下,真实的查询应该具有不等于 null 的 AdapterRam
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select Name,AdapterRAM from " + key+" where AdapterRAM is not null");
foreach (ManagementObject share in searcher.Get())
{
Console.WriteLine(share["Name"].ToString());
Console.WriteLine(share["AdapterRAM"].ToString());
}
结果是:
ATI Mobility Radeon HD 5650
字节数
有没有更好和更通用的方法来只在 WMI 中获取真正的 adpaters?