简体   繁体   中英

Use newer Windows 10 API in desktop apps

We're developing a desktop app that needs Bluetooth LE connectivity. It is possible to use the Windows 10 Bluetooth API in desktop apps, but there is no access to newer API features as far as I can tell.

The type BluetoothAdapter for instance cannot be accessed from a Windows 10 desktop app with the UwpDesktop nuget package installed. Is there some other way to access newer Windows 10 features? The specific feature we're after is BLE GATT services without pairing.

You can use newer Windows 10 APIs by referencing the winmd files from newer Windows 10 SDKs. The standard set of references are listed on https://docs.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-enhance

This means the latest SDK binaries can be found in the following locations:

C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade\Windows.WinMD
C:\Program Files (x86)\Windows Kits\10\References\10.0.17134.0\Windows.Foundation.FoundationContract\3.0.0.0\Windows.Foundation.FoundationContract.winmd
C:\Program Files (x86)\Windows Kits\10\References\10.0.17134.0\Windows.Foundation.UniversalApiContract\6.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

To find out if a certain API is supported you need to check if it has the DualApiPartitionAttribute attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM