[This is preliminary documentation and subject to change.]
The CertAddCTLLinkToStore function adds a link in a store to a CTL context in a different store. Instead of creating and adding a duplicate of a CTL context, this function adds a link to the original CTL context wherever it may be. Since the link provides access to the original CTL context, setting an extended property in the linked CTL context changes that property as seen in the original CTL's location and by any other links to that CTL. .
#include <wincrypt.h>
BOOL WINAPI CertAddCTLLinkToStore(
HCERTSTORE hCertStore, // in
PCTL_CONTEXT pCTLContext, // in
DWORD dwAddDisposition, // in
PCCTL_CONTEXT *ppStoreContext // out optional
);
If a matching CTL or a link to a matching CTL is not found in the store, a new link is added to the store.
TRUE if the function succeeded. FALSE if the function failed.
GetLastError returns the code for any failures using the following error codes:
Error code | Description |
---|---|
CRYPT_E_EXISTS | For a dwAddDisposition of CERT_STORE_ADD_NEW, the CTL already exists in the store. |
E_INVALIDARG | Invalid add disposition specified by the dwAddDisposition argument. |
Links cannot be added to a store that is opened as a collection. Stores opened as collections include all stores opened with CertOpenSystemStore or CertOpenStore using CERT_STORE_PROV_SYSTEM or CERT_STORE_PROV_COLLECTION. Also see CertAddStoreToCollection.
When links are used and CertCloseStore is called with CERT_CLOSE_STORE_FORCE_FLAG, the store using links must be closed before the store containing the original contexts is closed. If CERT_CLOSE_STORE_FORCE_FLAG is not used, the two stores may be closed in either order.
See the example with CertAddCertificateLinkToStore. This example will hold for CertAddCTLLinkToStore if all the references to "certificate" are changed to "CTL."
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use crypt32.lib.
CertOpenSystemStore, CertAddStoreToCollection, CertAddCRLLinkToStore, CertAddCertificateLinkToStore, CertFreeCTLContext