question

frankzhang-3676 avatar image
0 Votes"
frankzhang-3676 asked Castorix31 answered

Is there a way for common app(CompileAsWinRT is not enabled, just like win32 application) use winrt lib/dll ?

For some reason, I want to use BLE APIs , in Windows::Devices::Bluetooth, whitch seems winrt api. And I make a lib for BLE functions. But when I want to call it as a win32 application, I found that "CompileAsWinRT" should be set in the caller app's vcxproj, Otherwise a "Platform::COMException ^" exception will occured when run winrt APIs?
So is there a way for a common application to use winrt dll/libs?


windows-uwp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
2 Votes"
Castorix31 answered

It has been simplified with last versions of VS and Windows SDK

You now just have to do :

[C++] [Language] [C++ Language Standard] ISO C++17 Standard (/std:c++17)
[C++] [Language] [Conformance mode] No (/permissive)

Then

 include  <winrt/base.h>

and you can add the Namespaces you want, like :

 #include  <winrt/windows.devices.bluetooth.h>
 using namespace winrt::Windows::Devices::Bluetooth;




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.