簡體   English   中英

如何在Winform C#中獲取Bluetooth Device Com串行端口?

[英]How to get Bluetooth Device Com serial Port in winform C#?

如何獲取在Windows Form C#應用程序中配對的藍牙設備的端口詳細信息? 可以手動獲取所有端口名稱,但是我需要分配給特定藍牙設備的com端口名稱。

檢查這篇文章

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
            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM