I am pairing to or connecting to a Bluetooth device that has a serial port service associated with it. Is is possible to determine the COM port it registers too? If so, how?
A:
I just found the following C# WMI code seems to do the job. But is this reliable?
string deviceid = string.Empty;
ManagementObjectSearcher searcher = new ManagementObjectSearcher ( "Select * from WIN32_SerialPort" );
foreach ( ManagementObject port in searcher.Get () )
{
string name = port.GetPropertyValue ("Name" ) as string;
string provider = port.GetPropertyValue ( "ProviderType" ) as string;
if ( provider == null )
{
deviceid = port.GetPropertyValue ( "DeviceId" ) as string;
}
}
kenny
2009-08-31 22:11:20