Not able to receive UWP app window handle in C++ library integrated through winRT

Sudheendra Subbarao 6 Reputation points
2022-03-25T09:41:09.583+00:00

We are trying to build C++ library which is integrated in an UWP application using WinRT wrapper component.

In the library, we are trying to call the WebAuthNAuthenticatorMakeCredential API.
The API works fine in a C++ console app but we are not able to make the same API working in UWP app.

This API takes a HWND parameter as input . We have tried passing the widows handle of the UWP app but we get the below error message
0x8007109c
ERROR_NOT_SUPPORTED_IN_APPCONTAINER
This functionality is not supported in context of an app container

tried getting the hadnle in C++ using
HWND hWnd = GetActiveWindow();

also tried passing the handle from UWP using the below code

[ComImport, Guid("45D64A29-A63E-4CB6-B498-5781D298CB4F")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface ICoreWindowInterop
{
IntPtr WindowHandle { get; }
bool MessageHandled { set; }
}

dynamic corewin = Windows.UI.Core.CoreWindow.GetForCurrentThread();
var interop = (ICoreWindowInterop)corewin;
var handle = interop.WindowHandle;

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,948 questions
{count} votes