Questions tagged [c++-winrt]

C++/WinRT is a standard, native C++17 language projection for the Windows Runtime using modern C++ guidelines. It is the preferred alternative to C++/CX and WRL. This tag should be used with questions concerning using the features and functionality of C++/WinRT. Add the appropriate tag for the application type such as UWP as well. C++/WinRT is not C++/CX nor WRL so questions regarding those should probably not use this tag.

Filter by
Sorted by
Tagged with
31 votes
4 answers
14k views

What is C++/WinRT exactly?

I have been searching around the web. I get that: C++/WinRT is provided as a standard C++17 header file library But what is it really? Is it a new Object oriented replacement for the age-old Win32 ...
Aydan Haqverdili's user avatar
14 votes
2 answers
3k views

Can C++/CX and C++/WinRT be used in the same project?

Earlier this week, Kenny Kerr presented C++/WinRT at CppCon 20161. It is a Standard C++ projection for the Windows Runtime, based on Modern. As far as I understand, the C++/CX compiler/preprocessor/...
IInspectable's user avatar
  • 49.5k
10 votes
1 answer
434 views

Is there a way of getting ConnectionStatus from IVpnProfile in a UWP application?

I have the following WinRT code which works fine to discover active VPN Profiles: VpnManagementAgent vpn; auto profiles = vpn.GetProfilesAsync().get(); wprintf(L"Found %d profiles\n", profiles.Size())...
Paul Dolphin's user avatar
9 votes
1 answer
936 views

Can C++ coroutines contain plain `return` statements?

I am writing a C++ coroutine for a UWP control using C++/WinRT: winrt::fire_and_forget MyControl::DoSomething() { if (/* some condition */) { // Why does this work?! return; ...
citelao's user avatar
  • 5,506
9 votes
1 answer
2k views

Any recommendation in using smart pointers for COM-lite objects in C++/WinRT component? [closed]

C++/WinRT provides 3 flavors of smart pointers to use for COM objects - Microsoft::WRL::ComPtr, com_ptr, and ATL-based CComPtr. In my case, it is a COM-lite object, meaning it is NOT an in-proc or out-...
Snekithan's user avatar
  • 400
8 votes
2 answers
3k views

C++/WinRT, part of Windows SDK 17134 is not compatible with Visual Studio 15.8 Preview 3

Trying to compile the following code: #include <winrt/base.h> int main() {} With the following compiler options: /permissive- /std:c++latest With recently released Visual Studio 15.8 ...
Alexander Bessonov's user avatar
8 votes
0 answers
679 views

Using C++/WinRT dll in WPF with elevated rights application

I have got WPF c# server application (WCF) and want to use c++/WinRT dynamic library inside it. I can simply do this by using UWP desktop bridge with WPF app and UWP empty app that includes my dll. ...
Logman's user avatar
  • 4,100
8 votes
1 answer
2k views

Build Qt project with MinGW to use WinRT APIs

I would like to use libraries available via WinRT API (like these) from my application created using Qt 5.9.2 MinGW 32bit. I got Windows 10 OS. Now, I have set up a kit as presented below. Then, in ....
Paweł Skorupiński's user avatar
7 votes
0 answers
708 views

Windows Hello IR Camera - How to Modify the Current Mode of the InfraredTorchControl with C++/WinRT Media Foundation Platform APIs

Test Environment OS: Windows 11 Home 22H2 IR Camera: NexiGo HelloCam N930W Camera IDE: Visual Studio 2202 programming language: C++ 20 Application Kinds: Windows Desktop Application (C++/Winrt) [not ...
Andres Beltran's user avatar
6 votes
1 answer
3k views

Getting "a function that returns 'auto' cannot be used before it is defined" while using CoreDispatcher::RunAsync in C++/WinRT project

In my C++/WinRT project, I am trying to run some code on UI thread but getting an error that says: "winrt::impl::consume_Windows_UI_Core_ICoreDispatcher<winrt::Windows::UI::Core::ICoreDispatcher&...
GeniusZombie's user avatar
6 votes
1 answer
2k views

co_await expression needs await_ready function

I have a Win32 programm, where I want to add some winRT calls. Among other things I want to open a file without a GUI interface. I use the async file open call from the StorageFile class, because ...
user5580578's user avatar
  • 1,284
6 votes
1 answer
1k views

How to create a XAML custom control in code?

I am trying to implement a custom XAML control in code, using C++/WinRT. My attempted implementation, however, failed to compile. As a prove of concept I was using this code: #pragma once #include &...
IInspectable's user avatar
  • 49.5k
6 votes
1 answer
2k views

How to use the Windows Runtime to implement a C++ API using C#?

I'm working with a native C++ app which has a plugin system where it will LoadLibrary()/GetProcAddress() on a .dll to call functions. I'd like to implement one of these plugins, and inside the plugin ...
Litherum's user avatar
  • 23.1k
6 votes
0 answers
4k views

Guides for using WinUI with C++ [closed]

I'll try to summarize my issue as concisely as I can: I have a legacy C++ project that uses WinAPI to create and manage UI elements. I want to replace this with a more modern framework that supports ...
yah_nosh's user avatar
  • 165
5 votes
3 answers
1k views

How can I figure out the class name from an interface ID (IID) in WinRT?

I have a XAML C++/WinRT application based on the BlankApp template. As I built up the app, I realized that my application is throwing a lot of exceptions behind the scenes in my output window. The ...
mbl's user avatar
  • 845
5 votes
2 answers
1k views

C++/winRT xaml ContentDialog example

The documentation shows this C# snippet: async void DisplayDeleteFileDialog(){ ContentDialog deleteFileDialog = new ContentDialog{ Title = "Delete file permanently?", Content = "...
Jack Detrick's user avatar
5 votes
2 answers
2k views

How to add a new XAML "Page", and its associated code-behind files, in C++/WinRT in Visual Studio?

There are various related questions that give a hint how to add a new XAML Page properly to a WinRT/C++ project in Visual Studio, but none are specific to C++/WinRT. (I.e, here, here, and here.) ...
Dan Nissenbaum's user avatar
5 votes
2 answers
5k views

How do you create a classic win32 application window with WinRT?

What's the C++ WinRT equivalent for what in the Win32 API would be registering a window class, creating a window and then keeping it alive via a message pump loop? I'm currently looking at and ...
vlind's user avatar
  • 629
5 votes
1 answer
2k views

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

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 ...
dev54312's user avatar
5 votes
1 answer
5k views

C++11 threads to update MFC application windows. SendMessage(), PostMessage() required?

After spending a bit of time with simple UWP applications with C++/CX and ++/WinRT I have begun to enjoy some of the features of targeting that environment for Windows UI app development. Now having ...
Richard Chambers's user avatar
5 votes
1 answer
2k views

Consuming C++/WinRT Components from C#

I have a project (dynamic library) written in C++/CX, this project is consumed by a Windows 10 Universal App written in C# (targeting x86 and ARM32). I want to rewrite the library to C++/WinRT in ...
Tim Hansson's user avatar
5 votes
2 answers
2k views

Correct way to use multiple .IDL (MIDL) files within a single "Windows Runtime Component C++/WinRT" project

Visual Studio 2019. Windows Runtime Component C++/WinRT project. How do I follow and implement the recommendation: "We recommend that you declare each runtime class in its own Interface Definition ...
DefinedRisk's user avatar
5 votes
2 answers
240 views

Fast way to retrieve file sizes in a folder in UWP

I want to sum all file sizes in my application's TempState folder using below code which works fine. const auto tempFolder { ApplicationData::Current().TemporaryFolder() }; int64_t size { 0 }; const ...
Thomas Flinkow's user avatar
5 votes
0 answers
1k views

In which cases can CreateProcess be used on UWP?

I've noticed that CreateProcess is part of the Universal Windows Platform API since version 16299. To test it, I've made a quick UWP app based on the Blank App template (C++/WinRT) and wired up a ...
ArmsOfSorrow's user avatar
4 votes
3 answers
5k views

Error: this template attempted to load component assembly 'Microsoft.VisualStudio.Universal.TemplateWizards, Version=15.0.0.0

I'm using Visual Studio Community 2017 Version 15.7.1 on Windows 10 Home Version 10.0.16299 32-bit, Windows SDK Version 10.0.17134.12 and C++/WinRT Version 1.0.180505.2. When I try to create a new ...
Paul Jurczak's user avatar
  • 7,694
4 votes
1 answer
2k views

Build Qt project with VS C++ Compiler 15.0 with C++17 to use WinRT APIs

I would like to use libraries available via WinRT API (like these) from my UWP application created using Qt 5.9.2 for UWP 64bit (MSVC 2017). I got Visual Studio Build Tool 2017 v15.5.7 installed on my ...
Paweł Skorupiński's user avatar
4 votes
2 answers
957 views

Error C2664 'HRESULT IUnknown::QueryInterface(const IID &,void **)': cannot convert argument 1 from 'const winrt::guid' to 'const IID &'

This error happens to me when I use the helper function from microsoft docs to migrate to winrt from cx. I see a similar question here, but the solution mentioned doesn't seem to work for me. The ...
ssn's user avatar
  • 2,671
4 votes
1 answer
2k views

How could I know if I'm developing a c++/cx or c++/WinRT UWP application?

I'm creating a c++ UWP application and I want this app to be c++/WinRT because I read that c++/cx is not supported anymore. And this is how I created my application. VS 2017 -> File -> New -> Project.....
Ntk's user avatar
  • 155
4 votes
3 answers
1k views

WinUI3/Desktop/C++: Can't compile winrt::resume_foreground(Microsoft::System::DispatcherQueue const& dispatcher)

I want to use: co_await winrt::resume_foreground(window.DispatcherQueue()); (Type of "window" is: "winrt::Microsoft::UI::Xaml::Window") But I cannot compile it because winrt::...
Markus's user avatar
  • 51
4 votes
3 answers
6k views

VS 2017 & 2019 cannot find the WinRT header files, even on a fresh solution

So I'm trying to update a Win32 application to UWP using a "Windows Application Packaging Project", I'm hitting filesystem issues, which I expected and am trying to resolve them. In order to ...
Force Gaia's user avatar
4 votes
2 answers
760 views

How do I display a C++/WinRT FileOpenPicker from an exe without a console or window?

From a C++ executable on windows, I want to display a FileOpenPicker. To do this, I need a window to set as the object's owner: https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/display-...
MHebes's user avatar
  • 2,784
4 votes
1 answer
1k views

Consume Windows Runtime APIs from pure C

As far as I understand, Windows Runtime is the new infrastructure through which Windows exposes its APIs. My question is simple: how can I use that from pure C code? I don't mind writing more code, I ...
user1371019's user avatar
3 votes
2 answers
2k views

Is Win2D yet available in C++/WinRT?

I need to use win2D in my cppwinrt project. Using the Win2D sample file as a model I’ve tried to mimic its setup, putting in the package file for win2d from that project, duplicating the custom build ...
user3743210's user avatar
3 votes
1 answer
1k views

How to use midlrt.exe to compile .idl to .winmd?

Background: I need to build a Windows Runtime Component as part of a system that's set up to use CMake to generate its build system. As a preparatory step I'm trying to build it on the command line. ...
IInspectable's user avatar
  • 49.5k
3 votes
1 answer
500 views

How to get pixel data out of an IDXGISurface created with GPU access only?

In broad strokes, what I'm trying to accomplish is capture (part of) the screen and transform the capture into a digital image format. The following steps outline what I believe to be the solution: ...
IInspectable's user avatar
  • 49.5k
3 votes
3 answers
2k views

Does C++/WinRT offer a helper function to construct a GUID from a string literal?

Unlike C++/CX, there doesn't appear to be a wrapper type for GUIDs in C++/WinRT. It just uses the plain C GUID struct as-is. So the only way to construct an initialized GUID is by using aggregate ...
IInspectable's user avatar
  • 49.5k
3 votes
1 answer
1k views

How to get TypeName of underlying type in in C++/WinRT?

I'm trying to implement the ICustomPropertyProvider::Type() method, however I can't find a way to get TypeName of a C++/WinRT type. Apparently you have Object::GetType and T::typeid in C++/CX, but not ...
jvdh's user avatar
  • 308
3 votes
1 answer
684 views

Converting the C++/CX "delegate" object over to its equivalent in C++/WinRT

I'm new to WinRT. I'm converting my Windows UWP app written C++/CX over to C++/WinRT. I have a C++/CX ref class that basically does the same thing as the Microsoft.VisualStudio.PlatformUI....
Escovado's user avatar
  • 116
3 votes
1 answer
4k views

How can I specify "Target Platform Version" and "Target Platform Min. Version" when compiling with MSBuild, VS 2019, Platform Toolset v142

Project files have these settings in a PropertyGroup named Globals: <PropertyGroup Label="Globals"> ... <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <...
Patrick's user avatar
  • 167
3 votes
1 answer
855 views

How do i get the Instance of the class when i use winrt::static_lifetime?

I switched from C++/CX to C++/winrt not long ago and I'm currently stuck because I want to create a singleton winrt-class. I read about winrt::static_lifetime (https://learn.microsoft.com/en-us/uwp/...
Sneaky Hulk's user avatar
3 votes
2 answers
557 views

UWP App cannot pass Certification Kit tests on Windows 11

Edit 2 As @Calphalon points out (really appreciate your efforts with the MS engineer on this matter) in his answer, it's actually caused by a bug when WACK runs on W11. Edit 1: Oh no, I ran the ...
Guanyuming He's user avatar
3 votes
1 answer
700 views

How to get the parent of an object in WinUI3 with C++/WinRT?

This is how the xaml looks like: <ListView HorizontalContentAlignment="Stretch" x:Name="listViewMessages" Grid.Column="1" ...
Claudiu HBann's user avatar
3 votes
1 answer
376 views

What does the option "Fast ABI" do?

I can't find any documentation on this option. What does it do? Are there disadvantages to it or why is it not used by default? Edit: According to this CppWinRT NuGet package readme the C++/WinRT ...
Holo-Viktor's user avatar
3 votes
1 answer
387 views

How can one control the number of threads Windows ML is using for evaluation

I'm trying to benchmark Windows ML against other backends and see some weird distribution of inference times (see plot). This is with the CPU backend using the ARM64 architecture. On ARM there's no ...
etarion's user avatar
  • 17k
3 votes
2 answers
583 views

Array as value in ValueSet

My goal is to add array of strings as value into ValueSet. I can do it in C# without any problem, but facing some problems in C++-WinRT. I am trying to pass array_view to box_value in order to ...
miradham's user avatar
  • 2,305
3 votes
1 answer
3k views

How to use multiple precompiled headers; some from a library

I do not think this is unique to my projects, it applies to any C++ library that uses precompiled headers and a project that uses the library that has its own precompiled headers. Its just that C++/...
Brian Reinhold's user avatar
3 votes
1 answer
2k views

What is a composable runtime class?

I'm experimenting with creating a simple xaml appilcation using C++/WinRT. I come from a WPF background where it is pretty common to have a base class that implements INotifyPropertyChanged and have ...
Elad Maimoni's user avatar
  • 4,065
3 votes
1 answer
901 views

unresolved external for mouse pointer event exit handler for a Rectangle for XAML with C++/WinRT

I am working on a simple C++/WinRT UWP application to learn about how to link XAML events and the C++/WinRT source code for the actual handlers for these events. I have a XAML source for a simple ...
Richard Chambers's user avatar

1
2 3 4 5
15