The CryptEnumProviderTypes function is used to enumerate the types of providers supported on the machine.
#include <wincrypt.h>
BOOL WINAPI CryptEnumProviderTypes(
DWORD dwIndex, // in
DWORD *pdwReserved, // in
DWORD dwFlags, // in
DWORD *pdwProvType, // out
LPTSTR pszTypeName, // out
DWORD *pcbTypeName // in/out
);
This parameter can be NULL if you want to get the size of the name for memory allocation purposes. For more information, see the "Common In/Out Parameter Conventions" section at the beginning of this Reference.
Note that when processing the data returned in the buffer, applications need to 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 insure 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.
If the function succeeds, the return value is TRUE. If it fails, the return value is FALSE. To retrieve extended error information, use the GetLastError function.
The following table lists the error codes most commonly returned by the GetLastError function. The error codes prefaced by "NTE" are generated by the particular CSP you are using.
Error code | Description |
---|---|
ERROR_NO_MORE_ITEMS | There are no more items to enumerate. |
ERROR_NOT_ENOUGH_MEMORY | The operating system ran out of memory. |
NTE_BAD_FLAGS | dwFlags has an unrecognized value. |
NTE_FAIL | Something was wrong with the type registration. |
CryptEnumProviderTypes is used to enumerate the provider types on a machine. Once this is done, the providers for a specific type may be enumerated by using CryptEnumProviders.
long i;
DWORD dwErr;
// Loop through enumerating provider types.
for (i=0;;i++)
{
if (!CryptEnumProviderTypes(i, NULL, 0, &dwType, NULL, NULL))
{if (ERROR_NO_MORE_ITEMS != (dwErr = GetLastError()))
{printf("ERROR - CryptEnumProviderTypes : %X\n", dwErr);
}
break;
}
printf ("Provider Type %d\n", dwType);
}
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use advapi32.lib.
Unicode: Defined as Unicode and ANSI prototypes.