CryptUIDlgSelectCertificateFromStore function
The CryptUIDlgSelectCertificateFromStore function displays a dialog box that allows the selection of a certificate from a specified store.
Syntax
PCCERT_CONTEXT WINAPI CryptUIDlgSelectCertificateFromStore(
_In_ HCERTSTORE hCertStore,
_In_ HWND hwnd,
_In_opt_ LPCWSTR pwszTitle,
_In_opt_ LPCWSTR pwszDisplayString,
_In_ DWORD dwDontUseColumn,
_In_ DWORD dwFlags,
_In_ void *pvReserved
);
Parameters
- hCertStore [in]
-
Handle of the certificate store to be searched.
- hwnd [in]
-
Handle of the window for the display. If NULL, defaults to the desktop window.
- pwszTitle [in, optional]
-
String used as the title of the dialog box. If NULL, the default title, "Select Certificate," is used.
- pwszDisplayString [in, optional]
-
Text statement in the selection dialog box. If NULL, the default phrase, "Select a certificate you want to use," is used.
- dwDontUseColumn [in]
-
Flags that can be combined to exclude columns of the display.
- dwFlags [in]
-
Currently not used and should be set to 0.
- pvReserved [in]
-
Reserved for future use.
Return value
Returns a pointer to the selected certificate context. If no certificate was selected, NULL is returned. When you have finished using the certificate, free the certificate context by calling the CertFreeCertificateContext function.
Examples
The following example shows displaying a dialog box that allows the selection of a certificate from a specified store.
//-------------------------------------------------------------------- // Declare and initialize variables. HCERTSTORE hCertStore = NULL; PCCERT_CONTEXT pCertContext = NULL; TCHAR * pszStoreName = TEXT("MY"); //-------------------------------------------------------------------- // Open a certificate store. if ( hCertStore = CertOpenSystemStore( NULL, pszStoreName)) { fprintf(stderr,"The store has been opened.\n"); } else { printf("Unable to open store.\n"); exit(1); } //-------------------------------------------------------------------- // Display a list of the certificates in the store and // allow the user to select a certificate. if(!(pCertContext = CryptUIDlgSelectCertificateFromStore( hCertStore, // Open the store that contains the certificates to // display NULL, NULL, NULL, CRYPTUI_SELECT_LOCATION_COLUMN, 0, NULL))) { printf("Select Certificate UI failed.\n" ); exit(1); } // Use the certificate as needed. // ... //-------------------------------------------------------------------- // When all processing is completed, clean up. if(pCertContext) { CertFreeCertificateContext(pCertContext); } if(hCertStore) { if (!CertCloseStore(hCertStore,0)) { printf("CertCloseStore failed.\n" ); exit(1); } }
For another example that uses this function, see Example C Program: Listing the Certificates in a Store.
Requirements
|
Minimum supported client |
Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also