win32_USBDevice is missging from Win32 Classes

孤者浪人 提交于 2019-12-13 05:49:21

问题


I am trying to retrieve PID and VID of a connected USB device. Starting with this line of C# code:

System.Management.ManagementClass USBClass = new ManagementClass("Win32_USBDevice");

Then I got exception "ManagementException not found", Later I run into this link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394084(v=vs.85).aspx

It turned out Win32_USBDevice was not on the list at all. Tried Win32_USBController but didn't get what I wanted. Could anyone let me know if there is any substitute class on the list to extract PID and VID of a connected USB device?

Thanks in advance!


回答1:


Try this:

System.Management.ManagementClass USBClass = new ManagementClass("Win32_USBHub");




回答2:


Use Win32_PnPEntity. You can get the both the PID and VID of connected USB devices from Win32_PnPEntity by parsing the "PNPDeviceID".

Start with this example: Get List of connected USB Devices



来源:https://stackoverflow.com/questions/15660205/win32-usbdevice-is-missging-from-win32-classes

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