我可以制作仅头文件的库,例如 dll 和 lib 文件的 boost 吗?
环境:Window 10,Visual Studio 2015,Cmake
我正在 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)
奇怪的是
与具有相同代码的 UWP 应用程序配对正常。
在 UWP 和 WPF 应用程序中取消配对都可以。
不同之处在于,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)