How to get information from device manager?

牧云@^-^@ 提交于 2019-12-08 21:43:32

问题


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.

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.


回答1:


Microsoft provides a sample: 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).




回答2:


These APIs should get you going: 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+



来源:https://stackoverflow.com/questions/6942339/how-to-get-information-from-device-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!