Getting a description of a COM device

I read a lot of posts about this, but they are all either in C # or in MFC. I use regular Windows libraries, not the common MFC and ATL libraries.

I can easily list the available COM ports, but I donโ€™t know how to get the description, for example, in the device manager in Windows. I read MSDN and closest I came to SetupDiGetDeviceRegistryProperty (), but I would suggest that there should be a quick way to do this. I also found that Qt has QextSerialEnumerator :: getPorts (), but since I am not using Qt, I was hoping there would be something similar in WinAPI.

If anyone has a snippet for this, we will be very grateful.

+4
source share
2 answers

First, what description do you really need? You can get various information about COM ports using EnumPorts () and Registry-way. For example, a virtual COM port will be shown in the registry - this cannot be done by EnumPorts. Secondly, there are 9 different ways to list COM ports. Examples of their use here are http://www.naughter.com/enumser.html (I have the code from here in my project). Also note that the author uses many msvc-specific functions - atl containers for memory allocation, etc.

0
source

All I can say is that it does not use the setupDI WDM functions, if you donโ€™t know EXACTLY what you are doing, this is the way back for me, but check out the Windows DDK samples. I think the DLL implementation you see in the device manager is in / ports ...

The problem is that the serial ports are very old, so they were dragged for centuries and hacked together in Windows 7, so, for example, when you make changes to the COM port, you need to write to win. ini, but win.ini does not exist (wtf, I heard you say) that since any "changes" are returned back to the registry.

Any, like, good luck ..

0
source

Source: https://habr.com/ru/post/1380216/


All Articles