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!
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
Try this:
System.Management.ManagementClass USBClass = new ManagementClass("Win32_USBHub");