CertEnumCTLsInStore

The CertEnumCTLsInStore function enumerates all the CTL contexts in the store.

#include <wincrypt.h>
PCCTL_CONTEXT WINAPI CertEnumCTLsInStore(
  HCERTSTORE hCertStore,         // in
  PCCTL_CONTEXT pPrevCtlContext  // in
);
 

Parameters

hCertStore
Handle to the certificate store.
pPrevCtlContext
Pointer to the previous CTL context found. For more details, see the Remarks section.

Return Values

If a CTL is not found, returns NULL. Otherwise, the function returns a pointer to a read-only CTL_CONTEXT.

Call GetLastError to see the reason for any failures. This function has the following error codes:

Error code Description
E_INVALIDARG The hCertStore argument isn't the same as the hCertStore in the CTL context pointed to by the pPrevCtlContext argument.
CRYPT_E_NOT_FOUND Either no CTLs in the store or reached the end of the store's list.

Remarks

The pPrevCtlContext parameter must be NULL to get the first CTL in the store. Successive CTLs are enumerated by setting pPrevCtlContext to the PCCTL_CONTEXT (the pointer to the constant CTL_CONTEXT) returned by a previous call. The enumeration skips any CTLs previously deleted by CertDeleteCTLFromStore.

The returned pointer is freed when passed as the pPrevCtlContext on a subsequent call. Otherwise, the pointer must be 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.

Example

See CertEnumCertificatesInStore. Change all references to "certificate" in that example to "CTL."

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
  Windows: Requires Windows 95 OSR2 or later.
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.

See Also

CertFindCTLInStore