Compartilhar via


CertSaveStore (Windows CE 5.0)

Send Feedback

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

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 dwMsgAndCertEncodingType parameter specifies the message encoding type when dwSaveAs is set to CERT_STORE_SAVE_AS_PKCS7.

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

    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, 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 BLOB structure.

  • dwFlags
    [in] Reserved for future use and must be set to 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.

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.

Remarks

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

Requirements

OS Versions: Windows CE 3.0 and later.
Header: Wincrypt.h.
Link Library: Crypt32.lib.

See Also

CertOpenStore | CreateFile | WriteFile | BLOB

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.