CertDeleteCertificateFromStore function (wincrypt.h)

The CertDeleteCertificateFromStore function deletes the specified certificate context from the certificate store.


BOOL CertDeleteCertificateFromStore(
  [in] PCCERT_CONTEXT pCertContext


[in] pCertContext

A pointer to the CERT_CONTEXT structure to be deleted.

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 GetLastError. One possible error code is the following.

Return code Description
Indicates the store was opened as read-only and a delete operation is not allowed.


After a certificate is deleted from a store, all subsequent attempts to get or find that certificate in that store will fail. However, memory allocated for the certificate is not freed until all duplicated contexts have also been freed.

The CertDeleteCertificateFromStore function always frees pCertContext by calling the CertFreeCertificateContext function, even if an error is encountered. Freeing the context reduces the context's reference count by one. If the reference count reaches zero, memory allocated for the certificate is freed.


For an example that uses this function, see Example C Program: Deleting Certificates from a Certificate Store.


Requirement Value
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See also



Certificate Functions