>> We can get the COM port list available in the local system using the Name space System.Management.
>> The Serial port class's GetPortNames() method is used to get the COM Ports alone.
Eg.
String[] COMS =System.IO.Ports.SerialPort.GetPortNames();
>> We need to list the all the Ports available in the Local System then the ManagementObjectSearcher Class used.
Eg.
ManagementObjectSearcher ObjUsbSearcher = new ManagementObjectSearcher("Select * from WIN32_SerialPort");
>> The bellow code is Navigate through the ObjUsbSearcher
foreach(ManagementObject Port1 in ObjUsbSearcher.Get())
{
listBox1.Items.Add((String)Port1.GetPropertyValue("Name"));
}



0 comments:
Post a Comment