Discover serial ports in C#

余生长醉 提交于 2019-12-06 08:59:20

The SerialPort.GetPortNames() are the correct method to discover serial ports. But if you are using Windows 7, I think it could be issues with permissions on the registry keys this method lists. I found a post which describe this problem at Microsoft.com.

You could use Management Objects to query available COM ports. The interesting tables are:

You can explore these namespaces in the WMI Code Creator, and generate VBScript/VB/C# code.

SerialPort.GetPortNames() returns the list of COM ports install on the machine, not USB ports. I don't think Windows will provide you with a list of USB ports, only USB devices that are available.

Despite the name "Universal Serial Bus", they are not "Serial Ports" in the convential meaning.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!