What is a Windows USB device path and how is it formatted?

http://community.silabs.com/t5/Interface-Knowledge-Base/Windows-USB-Device-Path/ta-p/114059

 

Windows operating systems rely on a unique device path to uniquely identify each USB device/interface connected to the system. A device path string is used to communicate with a USB device and is passed to the CreateFile() Win32 API function.


USB Device Path Format


In most cases, Windows formats the USB device path as follows:


\?usb#vid_vvvv&pid_pppp#ssss#{gggggggg-gggg-gggg-gggg-gggggggggggg}


Where:
vvvv is the USB vendor ID represented in 4 hexadecimal characters.
pppp is the USB product ID represented in 4 hexadecimal characters.
ssss is the USB serial string represented in n characters.
gggggggg-gggg-gggg-gggg-gggggggggggg is the device interface GUID that is used to link applications to device with specific drivers loaded.


The CP210x VCP driver GUID is:


{A2A39220-39F4-4b88-AECB-3D86A35DC748}


The GUID is assigned in the driver or driver INF file and is used by the application to filter devices that have loaded that driver.


Composite USB Device Path Format For Interfaces


For a composite device with multiple interfaces, the device path for each interface might look something like:


\?usb#vid_vvvv&pid_pppp&mi_ii#aaaaaaaaaaaaaaaa#{gggggggg-gggg-gggg-gggg-gggggggggggg}


Where: 
vvvv is the USB vendor ID represented in 4 hexadecimal characters.
pppp is the USB product ID represented in 4 hexadecimal characters.
ii is the USB interface number.
aaaaaaaaaaaaaaaa is a unique, Windows-generated string based on things such as the physical USB port address and/or interface number.
gggggggg-gggg-gggg-gggg-gggggggggggg is the device interface GUID that is used to link applications to device with specific drivers loaded.


Unique Device Paths


Windows requires that the device path be unique for every USB device and interface. If two USB devices are plugged into the same machine with the same VID/PID/Serial string, then the USB Device Path Format described above won’t generate a unique string for the two devices. In this case, Windows generates a unique string similar to the format described in the Composite USB Device Path Format section. This method is also used if the USB device iSerial index is set to 0, indicating that the device does not have a serial string.


Registry Keys Using Device Path Information


The device path is useful for locating the USB device registry keys, where additional settings and information are stored for the device instance. USB device registry keys are stored in the following location:


[HKLMSYSTEMCurrentControlSetEnumUSBVID_vvvv&PID_ppppssss],


Where:
vvvv is the USB vendor ID.
pppp is the USB product ID.
ssss is the USB serial string or the unique, Windows-generate string.


For example, the CP210x VCP drivers stores the COM port number in the Device ParametersPortName registry key as shown in the figure below.


What is a Windows USB device path and how is it formatted?_第1张图片


Finding the Device Path Parameters using Device Manager


The vendor ID, product ID, and serial string or unique string can be obtained using device manager. Open the properties for a USB device and click on the 'Details' tab. Select the 'Device Instance Path' property from the combo box to display the device instance path which shares the components of the device path used for CreateFile(). The Device Instance Path is formatted slightly differently as shown in the figure below.


What is a Windows USB device path and how is it formatted?_第2张图片 

 

你可能感兴趣的:(windows)