Windows CE 3.0

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

BOOL WINAPI CertSaveStore(
DWORD dwMsgAndCertEncodingType, 
DWORD dwSaveAs, 
DWORD dwSaveTo, 
void *pvSaveToPara, 
DWORD dwFlags


[in] Handle of the certificate store to be saved.
[in] This parameter is not used and should be set to zero.
[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). However, Windows CE does not support PKCS # 7.
Note   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 dwEncodingType parameter specifies the message encoding type when dwSaveAs is set to CERT_STORE_SAVE_AS_PKCS7.

[in] Along with the pvSaveToPara parameter, specifies where to save the store as follows.

When the dwSaveTo parameter 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 pvSaveToPara parameter. After a successful save operation, the file pointer is positioned after the last write operation.

When the dwSaveTo parameter is set to CERT_STORE_SAVE_TO_MEMORY, the function saves the store to the memory BLOB passed in the pvSaveToPara parameter. Before use, the memory BLOB's pbData and cbData members must be initialized. Upon return, cbData is updated with the actual length. For a length-only calculation, pbData must be set to NULL. If pbData is non-NULL and cbData is not large enough, the function returns FALSE with a last error code of ERROR_MORE_DATA.

When the dwSaveTo parameter 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 pvSaveToPara parameter. The "_W" suffix indicates a Unicode file name; the "_A" suffix indicates an ASCII file name.

For the "_W" option, given LPCWSTR pwszFilename; pvSaveToPara = (void *) pwszFilename;

For the "_A" option, given LPCSTR pszFilename; pvSaveToPara = (void *) pszFilename;

Note   The default option, without "_A" or "_W" suffixed to the value name, is Unicode.
[in/out] Pointer used to save the store. May be a file handle or a pointer to a memory BLOB structure.
[in] Reserved for future use and must be zero.

Return Values

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE.

For extended error information, call the GetLastError function.

Note   The CreateFile or WriteFile errors 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.


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


Runs on Versions Defined in Include Link to
Windows CE OS 3.0 or later Wincrypt.h   Crypt32.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CertOpenStore, CertSaveStore, CreateFile, WriteFile, BLOB

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.