Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

Terms of Use
Privacy Policy
cryptenumproviders (advapi32)
 
.
Summary
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:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

[DllImport("Advapi32.dll")]
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))
        {
            installedCSPs.Add(pszName.ToString(),dwType);
        }
    }
    return installedCSPs;
}

Documentation

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 PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions