如何在winform C#中获取蓝牙设备Com串行端口?
如何获取在windows form c#应用程序中配对的蓝牙设备的端口详细信息? 我可以手动获取所有端口名,但我需要分配给特定蓝牙设备的com端口名。 Win32®是即插即用设备 你也可以在驱动程序上找到你的设备如何在winform C#中获取蓝牙设备Com串行端口?,c#,bluetooth,serial-port,C#,Bluetooth,Serial Port,如何获取在windows form c#应用程序中配对的蓝牙设备的端口详细信息? 我可以手动获取所有端口名,但我需要分配给特定蓝牙设备的com端口名。 Win32®是即插即用设备 你也可以在驱动程序上找到你的设备 // The WMI query const string QueryString = "SELECT * FROM Win32_PnPSignedDriver "; SelectQuery WMIquery
// The WMI query
const string QueryString = "SELECT * FROM Win32_PnPSignedDriver ";
SelectQuery WMIquery = new SelectQuery(QueryString);
ManagementObjectSearcher WMIqueryResults = new ManagementObjectSearcher(WMIquery);
// Make sure results were found
if (WMIqueryResults == null)
return;
// Scan query results to find port
ManagementObjectCollection MOC = WMIqueryResults.Get();
foreach (ManagementObject mo in MOC)
{
if (mo["FriendlyName"] != null && mo["FriendlyName"].ToString().Contains("YOUR_DEVICE_NAME"))
{}
//Check the mo Properties to find the COM port
}