public void loadPorts() { try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PnPEntity"); foreach (ManagementObject queryObj in searcher.Get()) { if (queryObj["Caption"].ToString().Contains("(COM")) { cmbPort.Items.Add(queryObj["Caption"]); } } } catch (ManagementException e) { } }
string[] ports = SerialPort.GetPortNames(); foreach (string p in ports) { Console.WriteLine(p); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)