如何识别哪些COM端口从C#程序连接到BlueTooth?
这是我的要求。让我们假设我的计算机中的COM端口连接到各种设备。假设我们有COM端口1到9,此时2、3、4、5和7已连接。现在,我需要确定端口2、3、4、5和7中哪些端口连接到BlueTooth设备?
我需要使用C#程序来完成此操作。有什么建议吗?
发布于 2011-05-13 22:56:01
参见http://32feet.codeplex.com/wikipage?title=Getting%20Virtual%20COM%20Port%20Names简介使用WMI查看端口硬件id中的BluetoothAddress。
C:\> Get-WmiObject -query "select DeviceID,PNPDeviceID from Win32_SerialPort"
DeviceID : COM66
PNPDeviceID : BTHENUM\{00001101-0000-1000-8000-00805F9B34FB}\7&1D80ECD3&0&00803A686519_C00000003
… …当然,我不是虚拟COM端口的粉丝,并且总是建议在可能的情况下使用直接套接字/API连接。http://32feet.codeplex.com/wikipage?title=Bluetooth%20Serial%20Ports http://32feet.codeplex.com/wikipage?title=General%20Bluetooth%20Data%20Connections
发布于 2013-10-12 01:17:02
您可以在注册表中查找。
string commport =(string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM", @"\Device\BthModem0", "");如果您有多个设备,还可以有"\ device \BthModem1“或"\Device\BthModem2”等。
https://stackoverflow.com/questions/5988469
复制相似问题