Extracting USB PID VID from DevicePath

Viewed 6636

When using SetupDiGetDeviceInterfaceDetail to retrieve a SP_DEVICE_INTERFACE_DETAIL_DATA relating to a connected USB device, a string called DevicePath is returned.

The string being returned is formatted like the following example:

\?\usb#vid_abcd&pid_1234#000000000#{xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

Question : Is the formatting/syntax of this string documented anywhere and / or known to be dependable across all versions of Windows XP/Vista/7/8?

I am experimenting with code to extract the VID and PID values from this string in order to identify the device being referred to, and would like to know if this is a robust way to retrieve the VID and PID values.

3 Answers
Related