I search how to get the device name of the material connected to the serial port.
I've two different types of material that can connect on it.
First one : a printer (only receives data and send nothing back) Second one : a balance (only send data and receives nothing)
How can I distinguish this two types of material?
Thanks.
try this:
ManagementObjectCollection ManObjReturn;
ManagementObjectSearcher ManObjSearch;
ManObjSearch = new ManagementObjectSearcher("Select * from Win32_SerialPort");
ManObjReturn = ManObjSearch.Get();
foreach (ManagementObject ManObj in ManObjReturn)
{
//int s = ManObj.Properties.Count;
//foreach (PropertyData d in ManObj.Properties)
//{
// MessageBox.Show(d.Name);
//}
MessageBox.Show(ManObj["DeviceID"].ToString());
MessageBox.Show(ManObj["PNPDeviceID"].ToString());
MessageBox.Show(ManObj["Name"].ToString());
MessageBox.Show(ManObj["Caption"].ToString());
MessageBox.Show(ManObj["Description"].ToString());
MessageBox.Show(ManObj["ProviderType"].ToString());
MessageBox.Show(ManObj["Status"].ToString());
}