目录


蓝牙问题

 尝试过如下方法都没有解决

1、使用工具删除

2、显示隐藏设备法:

3、官方删除注册法:

4、其他方法

5、终极解决办法

总结

后记


蓝牙问题

最近调试蓝牙 HID设备,发现蓝牙连接一次就不能再次连接,只能通过修改蓝牙mac地址重新连接,这就出现个问题,每修改一次程序就要修改一次mac地址,设备管理器就会多一个设备几次调试,蓝牙设备如下图所示:

android删除已配对设备 删除已配对蓝牙_HID

 尝试过如下方法都没有解决

1、使用工具删除


控制台删除法:复制下面程序粘贴到控制台运行。

$Source = @"
   [DllImport("BluetoothAPIs.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
   [return: MarshalAs(UnmanagedType.U4)]
   static extern UInt32 BluetoothRemoveDevice(IntPtr pAddress);

   public static UInt32 Unpair(UInt64 BTAddress) {
      GCHandle pinnedAddr = GCHandle.Alloc(BTAddress, GCHandleType.Pinned);
      IntPtr pAddress     = pinnedAddr.AddrOfPinnedObject();

      UInt32 result       = BluetoothRemoveDevice(pAddress);
      pinnedAddr.Free();
      return result;
   }
"@

Function Get-BTDevice {
    Get-PnpDevice -class Bluetooth |
      ?{$_.HardwareID -match 'DEV_'} |
         select Status, Class, FriendlyName, HardwareID,
            # Extract device address from HardwareID
            @{N='Address';E={[uInt64]('0x{0}' -f $_.HardwareID[0].Substring(12))}}
}

################## Execution Begins Here ################

$BTR       = Add-Type -MemberDefinition $Source -Name "BTRemover"  -Namespace "BStuff" -PassThru
$BTDevices = @(Get-BTDevice) # Force array if null or single item
Do {
   If ($BTDevices.Count) {
      "`n******** Bluetooth Devices ********`n" | Write-Host
      For ($i=0; $i -lt $BTDevices.Count; $i++) {
         ('{0,5} - {1}' -f ($i+1), $BTDevices[$i].FriendlyName) | Write-Host
      }
      $selected = Read-Host "`nSelect a device to remove (0 to Exit)"
      If ([int]$selected -in 1..$BTDevices.Count) {
         'Removing device: {0}' -f $BTDevices[$Selected-1].FriendlyName | Write-Host
         $Result = $BTR::Unpair($BTDevices[$Selected-1].Address)
         If (!$Result) {"Device removed successfully." | Write-Host}
         Else {"Sorry, an error occured." | Write-Host}
      }
   }
   Else {
      "`n********* No devices foundd ********" | Write-Host
   }
} While (($BTDevices = @(Get-BTDevice)) -and [int]$selected)

2、显示隐藏设备法:

 

3、官方删除注册法:

https://answers.microsoft.com/zh-hans/windows/forum/all/win10%E8%93%9D%E7%89%99%E8%AE%BE%E5%A4%87%E6%97%A0/dd641a9b-ca95-491a-8cd9-90747b36fe2c

4、其他方法

5、终极解决办法

     经过几天的折腾问题并没有解决,最后怀疑是系统问题,查看win10版本 windows10 1909  现在最新可升级版本是window  20H2,win10虽然很垃圾但是支持在线升级还是很人性的 不用重做系统。

经过一晚上折腾升级到最新版本。

 

android删除已配对设备 删除已配对蓝牙_android删除已配对设备_02

        升级完成后,在设备管理器中还是不能删除,慌了,在操作上述方法还是不好使,心态崩了。在准备放弃的时候打开了win10的蓝牙和其他设备,这里面能显示出之前的蓝牙了(后写的博客 蓝牙已经删除)

试了一下,删除设备,蓝牙居然删除了,喜出望外。蓝牙居然是这么删除的。

android删除已配对设备 删除已配对蓝牙_android删除已配对设备_03

总结

     win10系统通过设备管理器卸载蓝牙是卸载不掉的,卸载后扫描设备又会被从新添加,蓝牙只能通过win10系统提供的管理工具才能删除,但是有的版本win10(1909)并不能显示出蓝牙设备所以删除不了,

所以只能升级系统喽。

后记

     win10真是垃圾,蓝牙能删掉了,wifi又不好使了,频繁掉网,重新安装网卡驱动也不行,看来又得折腾几天了。