简体   繁体   中英

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

How do I get the port details of the Bluetooth device that I have paired within my windows form c# application? Manually I can get all port names but I need the com port name that allocated to particular Bluetooth Device.

Check this post

the Win32_PnPEntity is Plug and play devices MSDN

you can go on the drivers also to find your device

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM