【问题标题】:How to get Bluetooth Device Com serial Port in winform C#?如何在 winform C# 中获取蓝牙设备 Com 串口?
【发布时间】:2014-10-18 11:09:47
【问题描述】:

如何获取我在 windows 窗体 c# 应用程序中配对的蓝牙设备的端口详细信息? 手动我可以获得所有端口名称,但我需要分配给特定蓝牙设备的 com 端口名称。

【问题讨论】:

    标签: c# bluetooth serial-port


    【解决方案1】:

    Check this post

    Win32_PnPEntity 是即插即用设备MSDN

    您也可以在驱动程序上找到您的设备

                // 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
                }
    

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 1970-01-01
      • 2020-07-28
      • 1970-01-01
      • 1970-01-01
      • 2017-11-02
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      相关资源
      最近更新 更多