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