I’m writing an application that communicates by sending bytes to the USB port. I’d like to allow the user to choose the port and to do that, I use SerialPort.GetPortNames(). Unfortunately, it returns an empty array. The method supposedly reads the registry for data (HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM), but the SERIALCOMM directory is missing. When I run the program on Linux, it lists my four USB ports, as expected. How can I fix the registry/discover the ports in a different way?
I’m writing an application that communicates by sending bytes to the USB port. I’d
Share
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.