SerialPortStream uses two mechanisms to obtain details about serial ports: the registry; and the Windows Management Interface (WMI). There is one method compatible with System.IO.SerialPort, the other is new.

List of COM ports

This method is compatible with the Microsoft implementation
using System.Diagnostic;

foreach (string c in SerialPortStream.GetPortNames()) {
  Trace.WriteLine("GetPortNames: " + c);
}

Port Descriptions

To get a description about the serial port also:
using System.Diagnostic;

foreach (SerialPortStream.PortDescription desc in SerialPortStream.GetPortDescriptions()) {
  Trace.WriteLine("GetPortDescriptions: " + desc.Port + "; Description: " + desc.Description);
}

Last edited Sep 23, 2012 at 12:58 PM by jmcurl, version 2

Comments

No comments yet.