- using System.Management;
- using System.IO.Ports;
:: Write this code in page load event ::
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(
"Device ID : " + ManObj["DeviceID"] + "\n"
+ "PNP Device ID : " + ManObj["PNPDeviceID"] + "\n"
+ "Name : " + ManObj["Name"] + "\n"
+ "Caption : " + ManObj["Caption"] + "\n"
+ "Description : " + ManObj["Description"] + "\n"
+ "Provider Type : " + ManObj["ProviderType"] + "\n"
+ "Status : " + ManObj["Status"]);
}
No comments :
Post a Comment