Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function saves the certificate store to a file or to a memory BLOB.

Syntax

BOOL WINAPI CertSaveStore(
  HCERTSTORE 
hCertStore, 
  DWORD 
dwMsgAndCertEncodingType, 
  DWORD 
dwSaveAs, 
  DWORD 
dwSaveTo, 
  void* 
pvSaveToPara, 
  DWORD 
dwFlags
);

Parameters

hCertStore

[in] Handle to the certificate store to be saved.

dwMsgAndCertEncodingType

[in] Not used and should be set to zero.

dwSaveAs

[in] Specifies whether the store can be saved as a serialized store containing properties in addition to encoded certificates (CERT_STORE_SAVE_AS_STORE) or as a PKCS #7 signed message that does not include additional properties (CERT_STORE_SAVE_AS_PKCS7).

The CERT_KEY_CONTEXT_PROP_ID property and the related CERT_KEY_PROV_HANDLE_PROP_ID and CERT_KEY_SPEC_PROP_ID values are not saved to a serialized store.

The dwMsgAndCertEncodingTypeparameter specifies the message encoding type when dwSaveAsis set to CERT_STORE_SAVE_AS_PKCS7.

dwSaveTo

[in] Specifies the location where to save the store.

When the dwSaveToparameter is set to CERT_STORE_SAVE_TO_FILE, the function saves the store to the specified file. The file's handle is passed in the pvSaveToParaparameter. After a successful save operation, the file pointer is positioned after the last write operation.

When the dwSaveToparameter is set to CERT_STORE_SAVE_TO_MEMORY, the function saves the store to the memory BLOBpassed in the pvSaveToParaparameter. Before use, the memory BLOB's pbDataand cbDatamembers must be initialized. Upon return, cbDatais updated with the actual length. For a length-only calculation, pbDatamust be set to NULL. If pbDatais non-NULL and cbDatais not large enough, the function returns FALSE with a last error code of ERROR_MORE_DATA.

When the dwSaveToparameter is set to CERT_STORE_SAVE_TO_FILENAME_A, CERT_STORE_SAVE_TO_FILENAME_W, or CERT_STORE_SAVE_TO_FILENAME, the function opens the file, saves to it, and closes it. The file name is passed in the pvSaveToParaparameter. The _W suffix indicates a Unicode file name; the _A suffix indicates an ASCII file name.

For the _W option, given LPCWSTR pwszFilename,set pvSaveToPara= (void *) pwszFilename.

For the _A option, given LPCSTR pszFilename,set pvSaveToPara= (void *) pszFilename.

The default option, without _A or _W suffixed to the value name, is Unicode.

pvSaveToPara

[in, out] Pointer used to save the store. May be a file handle or a pointer to a memory BLOBstructure.

dwFlags

[in] Reserved for future use and must be set to zero.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

For extended error information, call the GetLastErrorfunction.

The CreateFileor WriteFileerrors can be propagated to this function. One possible error code is CRYPT_E_FILE_ERROR, which indicates that an error occurred while writing to the file.

Remarks

The desktop operating system supports the flag PKCS_7_ASN_ENCODING, but Windows Embedded CE does not and ignores the flag when it is specified.

Requirements

Header wincrypt.h
Library crypt32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also