如何获得在winform C#蓝牙设备的COM串口? [英] How to get Bluetooth Device Com serial Port in winform C#?

查看:1897
本文介绍了如何获得在winform C#蓝牙设备的COM串口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

推荐答案

<一个href=\"http://stackoverflow.com/questions/15079601/get-specific-com-port-for-particular-device-in-windows-8\">Check这个帖子

在Win32_PnPEntity是即插即用设备 MSDN

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
            }

这篇关于如何获得在winform C#蓝牙设备的COM串口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆