Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
cryptenumproviders (advapi32)
TODO - a short description

C# Signature:

[DllImport("advapi32.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern bool CryptEnumProviders(
    [MarshalAs(UnmanagedType.U4)] int dwIndex,
    [MarshalAs(UnmanagedType.U4)] ref int pdwReserved,
    [MarshalAs(UnmanagedType.U4)] int dwFlags,
    [MarshalAs(UnmanagedType.U4)] ref int pdwProvType,
    StringBuilder pszProvName,
    [MarshalAs(UnmanagedType.U4)] ref int pcbProvName);

Another kind of declaration:

[DllImport("advapi32.dll", EntryPoint = "CryptEnumProviders", SetLastError = true)]
static extern bool CryptEnumProviders(
    uint dwIndex,
    IntPtr pdwReserved,
    uint dwFlags,
    ref uint pdwProvType,
    StringBuilder pszProvName,
    ref uint pcbProvName);

VB Signature:

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!



Tips & Tricks:

Please add some!

Sample Code:

internal static extern bool CryptEnumProviders(
    int dwIndex,
    IntPtr pdwReserved,
    int dwFlags,
    ref int pdwProvType,
    StringBuilder pszProvName,
    ref int pcbProvName);

public static Dictionary<string, int> ReadAllProviders()
    Dictionary<string, int> installedCSPs = new Dictionary<string, int>();
    int cbName;
    int dwType;
    int dwIndex;
    StringBuilder pszName;
    dwIndex = 0;
    dwType = 1;
    cbName = 0;
    while (CryptEnumProviders(dwIndex, IntPtr.Zero, 0, ref dwType, null, ref cbName))
        pszName = new StringBuilder(cbName);

        if (CryptEnumProviders(dwIndex++, IntPtr.Zero, 0, ref dwType, pszName, ref cbName))
    return installedCSPs;


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version