CertEnumCTLsInStore function (wincrypt.h)

The CertEnumCTLsInStore function retrieves the first or next certificate trust list (CTL) context in a certificate store. Used in a loop, this function can retrieve in sequence all CTL contexts in a certificate store.


  [in] HCERTSTORE    hCertStore,
  [in] PCCTL_CONTEXT pPrevCtlContext


[in] hCertStore

Handle of a certificate store.

[in] pPrevCtlContext

A pointer to the previous CTL_CONTEXT structure found. It must be NULL to get the first CTL in the store. Successive CTLs are enumerated by setting pPrevCtlContext to the pointer returned by a previous call. This function frees the CTL_CONTEXT referenced by non-NULL values of this parameter. The enumeration skips any CTLs previously deleted by CertDeleteCTLFromStore.

Return value

If the function succeeds, the return value is a pointer to a read-only CTL_CONTEXT.

If the function fails and a CTL is not found, the return value is NULL. For extended error information, call GetLastError.

Some possible error codes follow.

Return code Description
Either no CTLs exist in the store, or the function reached the end of the store's list.
The handle in the hCertStore parameter is not the same as that in the CTL context pointed to by the pPrevCtlContext parameter.


The returned pointer is freed when passed as the pPrevCtlContext on a subsequent call. Otherwise, the pointer must be explicitly freed by calling CertFreeCTLContext. A pPrevCtlContext that is not NULL is always freed by this function (through a call to CertFreeCTLContext), even for an error.

A duplicate can be made by calling CertDuplicateCTLContext.


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 Trust List Functions