[This is preliminary documentation and subject to change.]
The CertGetStoreProperty function gets a store property.
#include <wincrypt.h>
BOOL CertGetStoreProperty(
HCERTSTORE hCertStore, // in
DWORD dwPropId, // in
void *pvData, // out
DWORD *pcbData // in, out
);
There is one predefined store property, CERT_STORE_LOCALIZED_NAME_PROP_ID, the localized name of the store.
This parameter can be NULL to set the size of this information for memory allocation purposes. For more information, see Common In/Out Parameter Conventions.
If the store property is found the function returns TRUE. pvDate points to the property and pcbData points to the length of the string. If the store property is not found, the function returns FALSE and GetLastError returns CRYPT_E_NOT_FOUND.
Store property IDs are properties applicable to an entire store. They are not properties on an individual certificate, CRL, or CTL context. Currently, no store properties are persisted.
//
// Example code for CertSetStoreProperty and CertGetStoreProperty
//
//
// handle_error is a function defined in a separate file.
//
HCERTSTORE hCertStore;
void *pvData=NULL;
DWORD cbData;
CRYPT_DATA_BLOB Property_Name_Blob;
// Open the MY certificate store.
// See CertOpenStore for details.
if ( hCertStore = CertOpenStore(
CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_CURRENT_USER,
L"MY"))
printf("The MY store is open. Continue. \n");
else
handle_error("The MY store did not open.");
// Prepare a data strucute to set a store property.
// Initialize the members of the CRYPT_DATA_BLOB.
Property_Name_Blob.pbData =(BYTE *) L"The name of MY Store";
Property_Name_Blob.cbData = (wcslen((LPWSTR) Property_Name_Blob.pbData)+1) * sizeof(WCHAR);
// Set the store's localized name property.
if (CertSetStoreProperty(
hCertStore,
CERT_STORE_LOCALIZED_NAME_PROP_ID,
0,
&Property_Name_Blob)
printf("The name of the store has been set. Continue. \n");
else
handle_error("Setting the store's localized name failed.");
// Call CerGetStorePropertyt a first time
// to get the length of the store name string to be returned
if(CertGetStoreProperty(
hCertStore,
CERT_STORE_LOCALIZED_NAME_PROP_ID,
NULL, // NULL on the first call
// to establish the length of the string to
// to be returned.
&cbData)))
printf("The first call succeed. Continue.\n");
else
handle_error("The first call to the function failed.");
// cbData is the length of a string to be allocated.
// Allocate the space for the string and call the function a
// the second time.
if(pvData = malloc(cbData)
printf("Memory is allocated. Continue. \n");
else
handle_error("Memory was not allocated.");
if(CertGetStoreProperty(
hCertStore,
CERT_STORE_LOCALIZED_NAME_PROP_ID,
pvData,
&cbData))
printf("The second call to the function worked. Continue.\n");
else
handle_error("The second call to CertGetStoreProperty failed.");
// Print the name of the store.
printf("The localized name is %S.\n",pvData);
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use crypt32.lib.