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
Download Visual Studio Add-In

CryptAcquireContext (advapi32)
 
.
Summary
Used to acquire a handle to a particular key container within a particular cryptographic service provider (CSP).

C# Signature:

[DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
[return : MarshalAs(UnmanagedType.Bool)]
   static extern bool CryptAcquireContext(ref IntPtr hProv, string pszContainer,
   string pszProvider, uint dwProvType, uint dwFlags);

VB .NET Signature:

Declare Function CryptAcquireContext Lib "advapi32.dll" (ByRef hProv As IntPtr, _
   pszContainer As String, pszProvider As String, dwProvType As Integer, _
   dwFlags As Integer) As Boolean

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

public class Crypt32
    {

[DllImport("advapi32.dll", SetLastError=true)]

        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool CryptAcquireContext(
        out IntPtr phProv,
        string pszContainer,
        string pszProvider,
        uint dwProvType,
        uint dwFlags);

}

.......

IntPtr hProv = new IntPtr();

bool res = Crypt32.CryptAcquireContext(out hProv, "user", null, PROV_RSA_FULL, CRYPT_NEWKEYSET);

Alternative Managed API:

TODO

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
Find References
Show Printable Version
Revisions