CryptDestroyKey (advapi32)
Last changed: carl_mailloux@DMR.CA-209.226.94.110

.
Summary
The CryptDestroyKey function releases the handle referenced by the hKey parameter. After a key handle has been released, it becomes invalid and cannot be used again. If the handle refers to a session key, or to a public key that has been imported into the CSP through CryptImportKey, this function destroys the key and frees the memory that the key occupied. Many CSPs overwrite the memory where the key was held before freeing it. However, the underlying public/private key pair is not destroyed by this function. Only the handle is destroyed.

C# Signature:

[DllImport("advapi32.dll", SetLastError=true)]
public static extern bool CryptDestroyKey(IntPtr phKey);

VB Signature:

Declare Function CryptDestroyKey Lib "advapi32.dll" (ByVal hKey As IntPtr) _
As <MarshalAs(UnmanagedType.Bool)> Boolean

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation