I am currently working on a C# program that is responsible for monitoring COM ports. In case of an error condition, the connected device should be restarted. For this purpose, all relevant devices are connected to the computer using a programmable Pegasus USB Hub. This hub allows individual ports to be turned on and off using a serial interface. However, since I don't know which physical port the devices are connected to, I need a way to map the Device Instance Path (ex. USB\VID_0AB4&PID_0010\IG011556) which I have, to their corresponding Location paths (ex. PCIROOT(0)#PCI(1D04)#USBROOT(0)#USB(4)) which I don't have. The location path will then allow me to determine on which physical port the device is connected and trigger a power cycle. Both of the mentioned attributes can be found in the device properties window of the device manager.
I have tried to find the data in the registry at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\DEVICE_ID and its subkeys. I was able to find the LocationInformation data (ex. Port_#0003.Hub_#0006) there, it matches the information in the device properties window. Example. However this information is insufficient, as some devices break the pattern and display different infomation (ex. 0000.0013.0002.001.000.000.000.000.000). I tried searching with Regedit for exact string displayed in the device properties but was not able to find it in the registry. I also looked for information in the Win32_PnPEntity or Win32_USBHub classes but there seems to be no additional infos there. I have read somewhere that it may be possible using the setupapi but I have found no examples and couldn't figure it out myself. Any ideas?