在桌面应用程序中使用较新的 Windows 10 API

Use newer Windows 10 API in desktop apps

我们正在开发需要蓝牙 LE 连接的桌面应用程序。可以在桌面应用程序中使用 Windows 10 蓝牙 API,但据我所知无法访问较新的 API 功能。

例如,无法从安装了 UwpDesktop nuget 包的 Windows 10 桌面应用访问类型 BluetoothAdapter。有没有其他方法可以访问更新的 Windows 10 项功能?我们追求的特定功能是无需配对的 BLE GATT 服务。

您可以通过引用较新的 Windows 10 SDK 中的 winmd 文件来使用较新的 Windows 10 APIs。标准参考集列在 https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-enhance

这意味着可以在以下位置找到最新的 SDK 二进制文件:

C:\Program Files (x86)\Windows Kits\UnionMetadata\Facade\Windows.WinMD
C:\Program Files (x86)\Windows Kits\References.0.17134.0\Windows.Foundation.FoundationContract.0.0.0\Windows.Foundation.FoundationContract.winmd
C:\Program Files (x86)\Windows Kits\References.0.17134.0\Windows.Foundation.UniversalApiContract.0.0.0\Windows.Foundation.UniversalApiContract.winmd
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.UI.Xaml.dll

要了解某个 API 是否受支持,您需要检查它是否具有 DualApiPartitionAttribute 属性。