PnPEntity Class of com0com driver
The virtual serial port driver for Windows.
Brought to you by:
vfrolov
I have little problem with listing these ports via WMI.
The problem is that com0com drivers have own PnPEntity Class diffrent than
Ports (COM & LPT ports)
Class = Ports
ClassGuid = {4d36e978-e325-11ce-bfc1-08002be10318}
This class includes serial and parallel port devices. See also the MultiportSerial class.
Does it have to be like this?
I have to do fancy things in C# to make list of Serial Port devices that contains com0com ports.
try { List<string> registryPortNames = SerialPort.GetPortNames().ToList(); ManagementObjectSearcher entitySearcher = new ManagementObjectSearcher(@"SELECT * FROM Win32_PnPEntity"); ManagementObjectCollection moc = entitySearcher.Get(); foreach (var n in registryPortNames) { foreach (var p in moc) { if (p["Caption"].ToString().Contains("("+n+")")) { Console.WriteLine("PnPEntity port found: " + p["Caption"]); var props = p.Properties.Cast<PropertyData>().ToArray(); retList.Add( new SerialPortInfo(n, p["Caption"].ToString(), p["PnPDeviceId"].ToString()) ); } } } }
Here is an example how I use code above.