C
Claire
I'm using the following code in an attempt to obtain a list of available
serial ports.
I expected to retrieve the same values as listed in hardware manager in
Control panel but I'm not.
I'm being returned COM1 and COM3 when I should be receiving COM1 and COM4.
I've also a USB to serial converter and although listed in control panel
correctly again my query is not returning this device.
What am I doing wrong please?
public void FillDeviceList(ComboBox.ObjectCollection cb)
{
cb.Clear();
SelectQuery selectQuery = new SelectQuery("select * from Win32_SerialPort");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(selectQuery);
//System.Array result
foreach (ManagementObject disk in searcher.Get())
{
cb.Add(disk["DeviceID"].ToString());
}
}
serial ports.
I expected to retrieve the same values as listed in hardware manager in
Control panel but I'm not.
I'm being returned COM1 and COM3 when I should be receiving COM1 and COM4.
I've also a USB to serial converter and although listed in control panel
correctly again my query is not returning this device.
What am I doing wrong please?
public void FillDeviceList(ComboBox.ObjectCollection cb)
{
cb.Clear();
SelectQuery selectQuery = new SelectQuery("select * from Win32_SerialPort");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(selectQuery);
//System.Array result
foreach (ManagementObject disk in searcher.Get())
{
cb.Add(disk["DeviceID"].ToString());
}
}