You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows系统中如何区分内置蓝牙适配器与外置USB蓝牙Dongle

切换Windows内置与外置蓝牙适配器的方法

在Windows蓝牙协议栈中,切换内置蓝牙适配器和外置USB蓝牙Dongle的活动无线电,可通过以下流程实现:

  • 禁用当前所有蓝牙适配器
  • 启用目标适配器,Windows蓝牙协议栈会自动完成后续的无线电激活操作

自动化实现上,可借助设备实例ID,通过setupapi、PowerShell的Disable-PnpDevice/Enable-PnpDevice cmdlet等工具完成批量禁用/启用操作。


区分内置与外置蓝牙适配器的技术方案

从Windows设备模型来看,内置蓝牙适配器(如Intel(R) Wireless Bluetooth(R))和外置USB蓝牙Dongle(如Realtek Bluetooth 5.1 Adapter)均归类为USB设备,但可通过以下技术手段区分二者:

1. PowerShell + WMI 查询

通过WMI的Win32_PnPEntity或Win32_USBControllerDevice类,结合设备的物理路径(PNPDeviceID)和设备描述判断:

  • 外置USB Dongle的PNPDeviceID通常以USB\开头,且路径中带有USB hub标识
  • 内置适配器的PNPDeviceID可能关联PCIe或内置USB总线(如PCI\前缀,或路径包含ACPI相关节点)

示例脚本:

# 获取所有蓝牙设备
$bluetoothDevices = Get-WmiObject Win32_PnPEntity | Where-Object { $_.Description -match "Bluetooth" }

foreach ($device in $bluetoothDevices) {
    $isExternal = $device.PNPDeviceID.StartsWith("USB\") -and $device.PNPDeviceID -notmatch "ACPI"
    $deviceType = if ($isExternal) { "外置USB蓝牙Dongle" } else { "内置蓝牙适配器" }
    Write-Host "设备名称: $($device.Description) | 类型: $deviceType | 设备实例ID: $($device.PNPDeviceID)"
}

2. .NET(Framework/.NET 5+)实现

通过System.Management命名空间访问WMI,或使用WinRT的Windows.Devices.Enumeration API查询设备的总线类型和可移动属性:

  • 内置适配器的总线类型通常为PCI或内置USB,外置Dongle为可移动USB总线

示例代码片段(.NET 6+):

using Windows.Devices.Enumeration;

var bluetoothSelector = BluetoothAdapter.GetDeviceSelector();
var devices = await DeviceInformation.FindAllAsync(bluetoothSelector);

foreach (var device in devices)
{
    if (device.Properties.TryGetValue("System.Devices.BusType", out var busType))
    {
        // BusType 1 = USB, 5 = PCI
        bool isExternal = (int)busType == 1 && device.Properties.ContainsKey("System.Devices.IsRemovable") && (bool)device.Properties["System.Devices.IsRemovable"];
        string deviceType = isExternal ? "外置USB蓝牙Dongle" : "内置蓝牙适配器";
        Console.WriteLine($"设备名称: {device.Name} | 类型: {deviceType} | 设备ID: {device.Id}");
    }
}

3. SetupAPI 原生调用

通过SetupAPI函数(如SetupDiGetClassDevs、SetupDiGetDeviceRegistryProperty)读取设备注册表属性:

  • 查询DeviceInstance的Capabilities值,判断是否为可移动设备(CM_DEVCAP_REMOVABLE)
  • 读取HardwareID或CompatibleID,区分内置与外置的总线标识

4. 32feet.NET 库

使用32feet.NET蓝牙开发库,通过BluetoothRadio类获取适配器信息,结合设备名称和厂商标识辅助判断:

  • 外置Dongle通常会在名称中带有"USB"或"Dongle"字样,内置适配器多为Intel、Broadcom等无线芯片厂商标识

示例代码:

using InTheHand.Net.Bluetooth;

foreach (var radio in BluetoothRadio.AllRadios)
{
    bool isExternal = radio.Name.Contains("USB") || radio.Name.Contains("Dongle");
    string deviceType = isExternal ? "外置USB蓝牙Dongle" : "内置蓝牙适配器";
    Console.WriteLine($"适配器名称: {radio.Name} | 类型: {deviceType} | 状态: {radio.Mode}");
}

内容的提问来源于stack exchange,提问作者Jason

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 01:21:00