How to open a serial port by friendly name?

后端 未结 8 1904
日久生厌
日久生厌 2020-11-29 02:10

friendly name = the name that appears in \"Device Manager\" under \"Ports (COM & LPT).

EDIT: two solutions provided below. One with WMI and another with SetupAPI

8条回答
  •  清酒与你
    2020-11-29 02:55

    If you are specifically using USB devices and not some other type of COM port, the cross-platform USB library libusbp has an example you can run that shows how to find the COM port name based on the USB product ID and vendor ID of the COM port.

    That is a different but probably better choice than trying to use the friendly name in the Device Manager. Perhaps libusbp could be extended to allow access to the friendly name if you really want that.

提交回复
热议问题