小编San*_*hoi的帖子

仅将 hpp 文件标头到 dll 和 lib

  • 我可以制作仅头文件的库,例如 dll 和 lib 文件的 boost 吗?

    • 看起来是的,对吧??
  • 环境:Window 10,Visual Studio 2015,Cmake

    • 如何将我的项目文件构建到 dll 和 lib

  • 很抱歉提出非常模糊的问题,但我是 C++ 的新手。所以任何参考和文档都会对我有所帮助。

c++ visual-studio-2015

5
推荐指数
0
解决办法
1225
查看次数

DeviceInformation PairAsync 在 WPF 中不起作用

我正在 WPF 应用程序中与下面的代码进行配对测试,但它总是失败并显示 Failed status 。

要使用BluetoothLe库,我刚刚添加了参考(C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd)

if (!DeviceInformation.Pairing.IsPaired)
{
  Logger.Info($"{DeviceInformation.Name} Try Pairing");
  var result = await DeviceInformation.Pairing.PairAsync(DevicePairingProtectionLevel.None);

  Logger.Info($"{result.Status}");
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是

  1. 与具有相同代码的 UWP 应用程序配对正常。

  2. 在 UWP 和 WPF 应用程序中取消配对都可以。

  3. 不同之处在于,UWP 应用程序始终会弹出系统对话框来确认配对和取消配对,但 WPF 应用程序不会显示任何对话框。

有谁能够帮助我?

解决了!谢谢。我刚刚使用了自定义配对。

public async void Pair()
{
    if (!DeviceInformation.Pairing.IsPaired)
    {
        Logger.Info($"{DeviceInformation.Name} Try Pairing");
        DeviceInformation.Pairing.Custom.PairingRequested += CustomOnPairingRequested;

        var result = await DeviceInformation.Pairing.Custom.PairAsync(
              DevicePairingKinds.ConfirmOnly, DevicePairingProtectionLevel.None);
        DeviceInformation.Pairing.Custom.PairingRequested -= CustomOnPairingRequested;

        Logger.Info($"{result.Status}");
    }

}


private void CustomOnPairingRequested(
      DeviceInformationCustomPairing sender, 
      DevicePairingRequestedEventArgs args)
{
    Logger.Info("Test");
    args.Accept();
}
Run Code Online (Sandbox Code Playgroud)

c# wpf bluetooth-lowenergy uwp

5
推荐指数
1
解决办法
3231
查看次数

标签 统计

bluetooth-lowenergy ×1

c# ×1

c++ ×1

uwp ×1

visual-studio-2015 ×1

wpf ×1