Can I use C++/WinRT in a non-UWP application?
Asked Answered
C

1

6

I just heard about C++/WinRT and I'm surprised that C++ has this runtime which adds high-level class wrappers like .NET does. But I don't want to distribute my apps as UWP apps. Can I use C++/WinRT in a non-UWP application?

Cicerone answered 25/9, 2018 at 17:54 Comment(0)
F
6

Yes, C++/WinRT (and WinRT in general) is not limited to UWP apps. You can write console apps, desktop apps, services, and even drivers with C++/WinRT. C++/WinRT is a header-only library. It's only requirement is that you use a modern C++ compiler that supports C++17.

Franni answered 26/9, 2018 at 0:17 Comment(5)
what !! even drivers !! but doesn't it depend on c++ runtime and user mode winapi functions which isn't available in kernel mode , sorry if I'm mistaken as I don't have much knowledge in kernel modeCicerone
Not kernel mode, but user mode drivers can now perform many of the functions that traditionally required a kernel mode driver. Microsoft ships drivers written with C++/WinRT for some of its newer hardware devices.Franni
@dev: UWP APIs callable from a classic desktop app explains, which UWP APIs can be called from classic desktop applications. Do note that the documentation is written with UWP-colored glasses, and it can be misleading (e.g. PasswordVault that only works as documented when called from a UWP app).Capriccio
One thing: how is it a header-only library while you have to include WindowsApp.lib to use it?Esophagus
It's a header only library in the sense that it does not require its own .cpp files to be compiled or add any runtime dependencies of its own. It does however depend on OS functions (for the Windows Runtime) and the linker has to know how to resolve those OS functions. That's what WindowsApp.lib is for.Franni

© 2022 - 2024 — McMap. All rights reserved.