【问题标题】:Windows.Devices.Radios are not working in the x86 platformWindows.Devices.Radios 在 x86 平台上不工作
【发布时间】:2021-09-22 05:32:19
【问题描述】:

我的目标是验证设备是否有蓝牙,如果有,则验证蓝牙是打开还是关闭。为此,我使用以下代码 sn-p。

public async Task<bool> GetBluetoothStatusAsync()
{
    var allRadio = await Radio.GetRadiosAsync();
    if (allRadio == null) return false;
    var bluetoothRadio = allRadio.FirstOrDefault(radio => radio.Kind == RadioKind.Bluetooth);
    return bluetoothRadio != null && bluetoothRadio.State == RadioState.On;
}

从桌面 Win32 应用程序调用时它不起作用。 如果目标平台设置为 x64,Windows.Devices.Radios 可以正常工作,但对于 x86,则无法正常工作。从windows git issues 看来,这是一个已知问题,但尚未解决。是否有解决此问题的方法?

【问题讨论】:

    标签: c# windows bluetooth bluetooth-lowenergy desktop-application


    【解决方案1】:

    这是一个旧线程,但以防万一其他人正在寻找:

    来自 Windows 文档:当从桌面应用程序 (Win32) 调用此方法时,它只会在应用程序针对目标架构本机编译时检索无线电实例(换句话说,当应用程序与计算机架构匹配时;所以在 x64 架构计算机上运行的 x86 应用程序不会看到任何无线电实例)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-28
      • 2011-02-27
      • 1970-01-01
      • 2012-01-02
      • 1970-01-01
      • 2014-09-20
      • 2017-09-07
      相关资源
      最近更新 更多