The EnumPorts class will find the COM ports, LPT ports, or both. If a new device arrives or leaves the list of devices gets refreshed.
The information you can retrieve is:
These can be retrieved by index from 1 to Count or by key (PortName, e.g. "COM1:").
Each refresh raises the Refresh event so you can update a menu, etc.
![Name: sshot1.png
Views: 27
Size: 2.7 KB]()
Menu populated by demo's Form1
![Name: sshot2.png
Views: 24
Size: 3.2 KB]()
Plugged in a USB serial IoT device. Got a Refresh event.
Menu updated to show the current list
![Name: sshot3.png
Views: 26
Size: 2.0 KB]()
Menu item clicked on, Form1 printed some of its info
No special requirements, but Windows 2000 or newer is required. Only tested on Windows 10 1709.
The information you can retrieve is:
- PortDescription
- PortName
- PortNumber
- PortType
These can be retrieved by index from 1 to Count or by key (PortName, e.g. "COM1:").
Each refresh raises the Refresh event so you can update a menu, etc.
Menu populated by demo's Form1
Plugged in a USB serial IoT device. Got a Refresh event.
Menu updated to show the current list
Menu item clicked on, Form1 printed some of its info
No special requirements, but Windows 2000 or newer is required. Only tested on Windows 10 1709.