4#include <winpr/tchar.h>
5#include <winpr/crypto.h>
12#include <cryptuiapi.h>
15int TestCryptoCertEnumCertificatesInStore(
int argc,
char* argv[])
19 LPTSTR pszNameString =
nullptr;
20 HCERTSTORE hCertStore =
nullptr;
37 hCertStore = CertOpenSystemStore(0, _T(
"MY"));
43 printf(
"Failed to open system store\n");
49 while ((pCertContext = CertEnumCertificatesInStore(hCertStore, pCertContext)))
52 CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
nullptr,
nullptr, 0);
56 pszNameString = (LPTSTR)calloc(status,
sizeof(TCHAR));
59 printf(
"Unable to allocate memory\n");
63 status = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
nullptr,
64 pszNameString, status);
71 _tprintf(_T(
"Certificate #%d: %s\n"), index++, pszNameString);
76 CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, pCertContext,
nullptr,
nullptr, 0,
81 if (!CertCloseStore(hCertStore, 0))
83 printf(
"Failed to close system store\n");