1

I'm trying to attach the Windows Hello dialog to an application. I found out that the IUserConsentVerifierInterop interface has an argument where I can attach the handle of the application, but I couldn't create an instance of the interface. I need help.

Check out this thread for more updates.

I still couldn't figure out why I can't call the IUserConsentVerifierInterop interface to use the RequestVerificationForWindowAsync() method.

I tried to create an instance of the IUserConsentVerifierInterop interface using CoCreateInstance()/ RoGetActivationFactory()/ winrt::get_activationFactory() methods, and get the similar errors :

object uninitialized

no information available in the symbol of userconsentverifier.dll

no such interface present

etc, and I couldn't initialize the instance of the interface.

code snippets:

c++

LPCOLESTR plpsz = L"{2D0F7985-9EE6-427C-AAAA-A9D72CBFA853}"; // userconsentverifier class clsid
LPCOLESTR clpsz = L"{39E050C3-4E74-441A-8DC0-B81104DF949C}"; // IUserConsentVerifierInterop interface clsid // check the registry for this value
LPCOLESTR dllname = L"Windows.Security.Credentials.UI.UserConsentVerifier";

CLSID pclsid{};
HRESULT RES3 = CLSIDFromString(plpsz, &pclsid);

CLSID cclsid{};
HRESULT res4 = CLSIDFromString(clpsz, &cclsid);

HSTRING hpclisd;
WindowsCreateString(dllname, wcslen(dllname), &hpclsid);
HRESULT RES1 = RoGetActivationFactory(hpclsid, cclsid, reinterpret_cast<void**>(&intop)); 

IUserConsentVerifierInterop* intop = nullptr;

HRESULT REX = CoCreateInstance(pclsid,nullptr,CLSCTX_INPROC_SERVER,cclsid,reinterpret_cast<void**>(&intop));  // the function to fetch instance of Iuserconsentverifierinterop

HRESULT hrt = GetActivationFactory(hpclsid, &intop); // to get the factory

winrt::com_ptr<IUserConsentVerifierInterop> interopFactory = winrt::get_activation_factory<Windows::Security::Credentials::UI::UserConsentVerifier,IUserConsentVerifierInterop>();

winrt::com_ptr<IDataTransferManagerInterop> dop = winrt::get_activation_factory<winrt::Windows::ApplicationModel::DataTransfer::DataTransferManager, IDataTransferManagerInterop>(); // this was just for verification this line should fetch the factory similar to the above method but both doesn't work
Ax1le
  • 6,563
  • 2
  • 14
  • 61
welsh
  • 11
  • 3
  • Please show a [mcve] instead of linking to off-site resources. As for the linked resource, it explains that you want to create an `IUserConsentVerifier` instance, and then request the `IUserConsentVerifierInterop` interface from it. – IInspectable Jun 14 '23 at 11:49
  • [For classes that implement IUserConsentVerifierInterop](https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/display-ui-objects#for-classes-that-implement-iuserconsentverifierinterop) lets us Call IDataTransferManagerInterop::ShowShareUIForWindow in C++/WinRT or the RequestVerificationForWindowAsync method of the Windows.Security.Credentials.UI.UserConsentVerifier**Interop** C# interop class in C#. You need to troubleshoot the *access_denied* error or use C#. – YangXiaoPo-MSFT Jun 15 '23 at 01:35
  • @IInspectable I want to create a instance of Iuserconsentverifierinterop interface and use the requestverificationasyncforwindows method of it, but while trying to create a instance using the above mentioned methods I get object uninitialized error and couldn't create the instance. – welsh Jun 15 '23 at 05:58
  • have tried all these methods in order to fetch the instance but every time I get these same error : 1. Object uninitialized 2. No information of the instance from the respective dll eg:userconsentverifer.dll 3.E_NOINTERFACE : no such interface ETC – welsh Jun 15 '23 at 06:11
  • Please add the code [to the question](https://stackoverflow.com/posts/76473079/edit). Regardless, my first comment sill holds. There's no point in creating an interop interface in isolation. You'll want to create an object and then request the interop interface from that object. – IInspectable Jun 15 '23 at 06:48
  • could you be more elaborate on requesting the interop interface from the object as im new to windows apis. Have also edited the question PS: also new to stackoverflow – welsh Jun 15 '23 at 07:02
  • @YangXiaoPo-MSFT my requirement is that i need to use c++. Im trying to troubleshoot the access_denied error, if in case anybody has resolved it let me know. – welsh Jun 15 '23 at 07:08
  • Please show a full example. The code provided doesn't compile, as there are lots of undefined identifiers. Requesting an interface from a COM/WinRT object is performed through a call to [`QueryInterface`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)). C++/WinRT provides the [`as`](https://learn.microsoft.com/en-us/uwp/cpp-ref-for-winrt/com-ptr#com_ptras-function) function template for convenience, that wraps the `QueryInterface` call and error handling. – IInspectable Jun 15 '23 at 08:27
  • @IInspectable the code is pretty lengthy as it required various headers and I would be able to upload it here so if there is a means of direct conversation it would be better... – welsh Jun 15 '23 at 09:46
  • As for the [QueryInterface](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface(refiid_void)) It can be called only when a instance which has inherited the IUnknown interface, I wasn't able to create a instance of [IUserconsentVerifierInterop](https://learn.microsoft.com/en-us/windows/win32/api/userconsentverifierinterop/nn-userconsentverifierinterop-iuserconsentverifierint) which inherits the IUnknow interface. – welsh Jun 15 '23 at 09:46
  • If you cannot show a complete sample, at least make sure the little we have is useful. `hpclsid`, for example, comes out of nowhere, with no way to know what it is. You're still missing the broader picture here, though: Interop interfaces aren't intended to be constructed by client code. They are meant to be *implemented* by other objects (that can be constructed). You'll have to let go the idea to construct an instance of `IUserConsentVerifierInterop`. Make sure to learn about [COM](https://learn.microsoft.com/en-us/windows/win32/com/com-fundamentals). – IInspectable Jun 15 '23 at 10:03
  • You could have gone through the methods I have mentioned above and got to know what hpclsid was In [RoGetActivationFactory](https://learn.microsoft.com/en-us/windows/win32/api/roapi/nf-roapi-rogetactivationfact) the hpclsid is activatableClassId in type HSTRING – welsh Jun 15 '23 at 10:25
  • but I have seen examples around the internet to create a instance using the above methods that i have mentioned only that I couldn't create it. wanted to know if i was missing something. There are examples in rust also trying the same to get the instance and use the [RequestVerificationForWindowAsync](https://learn.microsoft.com/en-us/windows/win32/api/userconsentverifierinterop/nf-userconsentverifierinterop-iuserconsentverifierinterop-requestverificationforwindowasync) to set the owner for the windows hello dialog box – welsh Jun 15 '23 at 10:29
  • @IInspectable one such [Example](https://github.com/microsoft/windows-rs/issues/1565) – welsh Jun 15 '23 at 10:32
  • This is from the [example](https://github.com/microsoft/windows-rs/issues/1565#issuecomment-1050308352) you linked to: *"Your first mistake was thinking that `IUserConsentVerifierInterop` was a COM class you could create with `CoCreateInstance`. Instead, it is just an interface that the `UserConsentVerifier` class factory implements."* Which is remarkably similar to what I have been saying all along. The only detail I didn't know is that the interop interface is implemented on the class factory, rather than an `IUserConsentVerifier` instance. – IInspectable Jun 15 '23 at 10:46
  • yes but in that [example](https://github.com/microsoft/windows-rs/issues/1565#issuecomment-1050308352) he was successfully able to create an instance from the class factory and able to retrieve the instance/factory using the [Rogetactivationfactory](https://learn.microsoft.com/en-us/windows/win32/api/roapi/nf-roapi-rogetactivationfactory) But still I couldn't. Maybe I missed something while linking or that by default windows does not expose these interfaces. if so I need a substitution api to resolve my issue :( – welsh Jun 15 '23 at 12:31
  • It's still unclear what *your* code does. I'm not going to guess, and piece things together. Please show a [mcve]. If you cannot condense this down into less than 15 lines of code, re-read the instructions in the previous link, and re-iterate. There is no *"substitute API"* either, for obvious reasons. – IInspectable Jun 15 '23 at 13:25
  • Now, just to get the elephant in the room out of the way: You are running Windows 11, as the [documentation](https://learn.microsoft.com/en-us/windows/win32/api/userconsentverifierinterop/nn-userconsentverifierinterop-iuserconsentverifierinterop) requires you to. Is that correct? – IInspectable Jun 15 '23 at 13:34
  • yes, and also tried with windows 10 as the userconsentverifier.h was available in the lower versions too, but still same error – welsh Jun 16 '23 at 14:42
  • I cannot reproduce using `IDataTransferManagerInterop::ShowShareUIForWindow` as I said in [the thread](https://learn.microsoft.com/en-us/answers/questions/1301447/im-in-need-of-to-use-the-iuserconsentverifierinter). But how do you call `IUserConsentVerifierInterop::RequestVerificationForWindowAsync`? Could you please show a minimal, reproducible sample without private information? – YangXiaoPo-MSFT Jun 19 '23 at 05:22
  • added the reproducible example please check and let me know.. – welsh Jun 20 '23 at 06:19
  • @IInspectable any idea why ? – welsh Jun 21 '23 at 07:37

0 Answers0