I've been reading a lot of posts on SO about this but all of them are either in C# or MFC. I'm using the normal windows libraries and not the MFC shared libraries nor ATL.
I can easily enumerate the available COM ports but I don't know how to obtain the description as, for example, seen in the Device Manager within Windows. I've been reading through the MSDN and the closest I've come is SetupDiGetDeviceRegistryProperty() but I'd imagine there must be a quick way to do this. I've also found that Qt has QextSerialEnumerator::getPorts() but since I'm not using Qt I was hoping there would be something similar available from the WinAPI.
If someone has a snippet for doing so it would be greatly appreciated.
preguntado el 08 de noviembre de 11 a las 15:11
First of all, what kind of description are you really need? You can obtain different info about COM-ports by EnumPorts() & Registry-way. For example, registry-way will show virtual COM-port - this one EnumPorts can't do. The second thing - there is 9 different ways of enumerating COM-ports. The examples of their usage is here - http://www.naughter.com/enumser.html (i've used some code from here in my project). Also, note that the author use many msvc-specific features - atl containers for memory allocating and etc.
All i can say is don't use the setupDI WDM functions if you don't know EXACTLY what you are doing, this is way back for me but check the windows DDK samples i think the dll implementation you see in device manager is in /ports...
The issue is that serial ports are very very old, so they've been dragged through the ages and hacked together into windows 7, so for example when you make a change to a COM port then you have to write to win.ini, but win.ini doesn't exist (wtf i hear you say) that's because any "changes" get bounced back into the registry.
Any how, good luck..