Is CryptUIDlgSelectCertificateFromStore not supported in win32?

68 views Asked by At

Is CryptUIDlgSelectCertificateFromStore not supported in win32 applications ?

I tried to show the list of Certificates from store, but it lists only one certificate and also not let select any other certificate.

Code snippt:

HCERTSTORE hCertStore = CertOpenSystemStore(NULL, L"MY");

CryptUIDlgSelectCertificateFromStore(hCertStore, GetForegroundWindow(), L"Select Certificate", L"Select Certificate", CRYPTUI_SELECT_ISSUEDBY_COLUMN| CRYPTUI_SELECT_INTENDEDUSE_COLUMN
        | CRYPTUI_SELECT_LOCATION_COLUMN| CRYPTUI_SELECT_EXPIRATION_COLUMN, 0, NULL);

Also click on "more option" it is causing the crash.

2

There are 2 answers

0
万顷茫然 On

Your code is correct. The reason, as said by Dialecticus, is in other parts. Microsoft supports this win32api, in higher than Windows XP Systems. Refer to:CryptUIDlgSelectCertificateFromStore.

1
anup kataria On

It seems the visual studio debugger is the culprit here. When I run the above code using Visual studio more choice throws error :

'testApp.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.Graphics.dll'. 
Exception thrown at 0x7564D8A2 (KernelBase.dll) in testApp.exe: 0x40080202: WinRT transform error (parameters: 0x8000000B, 0x80070490, 0x00000014, 0x02F6C5E4).
Exception thrown at 0x7564D8A2 (KernelBase.dll) in testApp.exe: WinRT originate error - 0x80070490 : 'Windows.Graphics.Display: GetForCurrentView must be called on a thread that is associated with a CoreWindow.'.
Exception thrown at 0x7564D8A2 in testApp.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x02F6CF40.

The program '[624] testApp.exe' has exited with code 0 (0x0).

Where as if run Application as independent binary it works !!!