views:

27

answers:

1

I'm trying to get a list of available COM ports with the "Windows 2000"-method explained here:
http://www.codeproject.com/KB/system/setupdi.aspx

My current code: http://pastebin.ca/1977670
This is what I get:

\\?\ftdibus#vid_0403+pid_6001+ftf479xra#0000#{86e0d1e0-8089-11d0-9ce4-08003e301f73}
USB Serial Port (COM13)
USB Serial Port

\\?\hdaudio#func_02&ven_11c1&dev_1040&subsys_11c10001&rev_1002#4&ddab605&0&0101#{86e0d1e0-8089-11d0-9ce4-08003e301f73}
Agere Systems HDA Modem
Agere Systems HDA Modem

I looked through the different options of SetupDiGetDeviceRegistryProperty, but I can't find the right one to get the actual COM port number. (see http://msdn.microsoft.com/en-us/library/ff551967(VS.85).aspx)

I could look for COMXXX in the friendly name (via regex or whatever..), but I don't think that this would be the correct solution...

+1  A: 

You can use SetupDiOpenDevRegKey to open the device's registry and query the "PortName" value; this will give you back something like "COM4". There are a few more ways to query COM ports.

Luke