windows 如何从设备管理器获取信息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6942339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get information from device manager?
提问by Afra
How can I, in my C# applictation, read specific information about a device? I have tried WMI and it does not provide the information that I need.
如何在我的 C# 应用程序中读取有关设备的特定信息?我尝试过 WMI,但它没有提供我需要的信息。
The information that I want is stored in the Details tab of a device and the information I want there is "Parent".
我想要的信息存储在设备的“详细信息”选项卡中,我想要的信息是“父级”。
I have also looked in regedit, without any luck.
我也看过regedit,没有任何运气。
采纳答案by Ben Voigt
Microsoft provides a sample: http://support.microsoft.com/kb/311272
微软提供了一个示例:http: //support.microsoft.com/kb/311272
From C#, it might be easier to capture the output of devcon than integrating the APIs. If you feel comfortable with it, C++/CLI is by far the easiest way to get device information into .NET (I've done this before).
在 C# 中,捕获 devcon 的输出可能比集成 API 更容易。如果您对它感到满意,C++/CLI 是迄今为止将设备信息获取到 .NET 的最简单方法(我之前已经这样做过)。
回答by James Johnston
These APIs should get you going: http://msdn.microsoft.com/en-us/library/ff550630(VS.85).aspx#retrieving_the_parent_of_a_device_inst
这些 API 应该可以帮助您:http: //msdn.microsoft.com/en-us/library/ff550630(VS.85).aspx#retrieving_the_parent_of_a_device_inst
Looks like SetupAPI can be used as an alternative on Windows Vista or newer. The above method works on Win2000+
看起来 SetupAPI 可以用作 Windows Vista 或更新版本的替代方案。以上方法适用于Win2000+