What is proper way to detect all available serial ports on Windows?

前端 未结 6 1438
借酒劲吻你
借酒劲吻你 2020-12-09 06:07

There are several ways to list serial ports under Windows but I\'m not sure what is the proper way: the way that does detect all serial ports that are available.

One

6条回答
  •  情书的邮戳
    2020-12-09 06:34

    If you can access the registry, the HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM key contains a list of COM ports Windows currently supports (in some cases, this information may be stale/incorrect; like, I suspect, when a plug & play device providing serial ports has not completed detection/installation or has been recently removed).

    This is the way .NET Framework's SerialPort.GetPortNames() method reports available COM ports, and the above information is derived from the linked page.

提交回复
热议问题