如何通过WMI查询获取PCIController信息?
我正在使用以下代码来获取有关我的 PCIController 的一些信息,
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_PCIController");
foreach (ManagementObject cdrom in searcher.Get())
{
Console.WriteLine("PCIController Name: {0}", cdrom.GetPropertyValue("Caption"));
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
但它一直抛出“无效类”异常。我使用随 Windows 安装的“wbemtest.exe”工具运行查询,并且出现相同的错误。我在 MSDN 上检查了 CIM_PCIController Class ,它看来我的代码没问题。但为什么会出现“无效类异常”呢?有人可以帮助我吗,我只想从我的 PCI 控制器设备获取一些信息。
非常感谢。
I am using the following code to get some info about my PCIController
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_PCIController");
foreach (ManagementObject cdrom in searcher.Get())
{
Console.WriteLine("PCIController Name: {0}", cdrom.GetPropertyValue("Caption"));
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
But it kept throwing "Invalid Class" exception. And I run my query with "wbemtest.exe" tool which is installed with Windows, and the same error there is. I checked the CIM_PCIController Class on MSDN and it seems my code is ok. But why the "Invalid Class exception"? Could someone help me, I just want to get some info from my PCI Controller device.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从您引用的文档页面:
这意味着它无法通过 WMI 获得。话虽这么说,您也许可以通过 Win32_PnPEntity 内容来找到您要查找的内容。
From the documentation page you cited:
This means it is not available through the WMI. That being said you might be able to go through the Win32_PnPEntity stuff to find what you are looking for.