Windows USB Device Location

1.3k views Asked by At

I am looking for the proper WMI Win32 or CIM Class property to find the location of a USB device. In device manager, shown below, the Location is known as "Port_#0002.Hub_#0009". Any ideas on the class and property that this is in the Windows API or if it is an arbitrary value Device Manager gives another property which is more cryptic. If the latter, what is the "more cryptic" class and property?

Image: https://i.stack.imgur.com/7Miwp.png

2

There are 2 answers

0
Preston On

You might cross-reference the Port_#X.Hub_#Y with the output of USBView. I've used this tool numerous times to get information about the existing USB tree.

The USBView sample is available in the WDK. If you are unfamiliar with this, simply run it - this tool walks the entire USB tree on the system and prints out information and descriptor listings for each device, as well as locations on the host controllers and hubs.

Start at the RefreshTree() function in this sample, you can then follow the code to see how it enumerates the host controllers, hubs and finally devices.

The easiest way to get the source to this sample is to install the 7.1.0 WDK which is currently available here: http://www.microsoft.com/en-us/download/details.aspx?id=11800

0
DS. On

Use API SetupDiGetDeviceRegistryProperty and const parameter SPDRP_LOCATION_INFORMATION.