Export (0) Print
Expand All
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.


Windows Mobile 6.5
A version of this page is also available for

This function retrieves the first or next available cryptographic service provider (CSP). Used in a loop, this function can retrieve in sequence all of the CSPs available on a computer.

BOOL WINAPI CryptEnumProviders( 
  DWORD dwIndex, 
  DWORD* pdwReserved, 
  DWORD dwFlags, 
  DWORD* pdwProvType, 
  LPTSTR pszProvName, 
  DWORD* pcbProvName


[in] Index of the next provider to be enumerated.


[in] Reserved for future use and must be set to NULL.


[in] Reserved for future use and must be set to zero.


[in] Pointer to the DWORD value that designates the type of the enumerated provider.


[out] Pointer to a buffer that receives a null-terminated string from the enumerated provider.

This parameter can be NULL to set the size of the name for memory allocation purposes.


[in, out] On input, pointer to a DWORD value that specifies the size, in bytes, of the buffer pointed to by the pszProvName parameter. On output, the variable pointed to by this parameter contains the number of bytes stored in the buffer.

When processing the data returned in the buffer, applications must use the actual size of the data returned. The actual size may be slightly smaller than the size of the buffer specified on input. On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer. On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.

TRUE indicates success. FALSE indicates failure. To get extended error information, call the GetLastError function.

The following table shows the common values for the GetLastError function. The error values prefaced by NTE are generated by the particular CSP you are using.

Value Description


The pszProvName buffer was not large enough to hold the provider name.


There are no more items to enumerate.


The operating system ran out of memory.


dwFlags has an unrecognized value.


Something was wrong with the type registration.

This function enumerates the providers on a machine. The provider types may be enumerated by using the CryptEnumProviderTypes function.

If the registry does not contain the provider type, the CryptEnumProviders function call fails with ERROR_INVALID_PARAMETER.

Windows Embedded CE does not support the ANSI version of this function.

long i;
LPTSTR pszName;
DWORD dwType;
DWORD cbName;
DWORD dwErr;
// Loop through enumerating provider types.
for (i=0;;i++)
if (!CryptEnumProviders(
 i, // in- dwIndex
 NULL, // in- pdwReserved- set to NULL
 0, // in- dwFlags- set to 0
 &dwType, // out- pdwProvType
 NULL, // out- pszProvName- NULL on the first call
 &cbName // in, out-pcbProvName
 {if (ERROR_NO_MORE_ITEMS != (dwErr = GetLastError()))
 {printf("ERROR - CryptEnumProviders : %X\n", dwErr);
if (NULL == (pszName = (LPTSTR)LocalAlloc(LMEM_ZEROINIT, cbName)))
 {printf("ERROR - LocalAlloc failed!\n");
if (!CryptEnumProviders(
 &cbName // pcbProvName- size of pszName
 {if (ERROR_NO_MORE_ITEMS != (dwErr = GetLastError()))
 {printf("ERROR - CryptEnumProviders : %X\n", dwErr);
printf ("Provider %s is type %d\n", pszName, dwType);

Windows Embedded CEWindows CE 2.10 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2015 Microsoft