Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtaining the description of a COM device

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.

like image 564
Yonathan Avatar asked Nov 13 '22 14:11

Yonathan


1 Answers

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.

like image 136
Roman Kr Avatar answered Dec 27 '22 19:12

Roman Kr