CryptReleaseContext function (wincrypt.h)
An application calls this function after finishing the use of the CSP. After this function is called, the released CSP handle is no longer valid. This function does not destroy key containers or key pairs.
BOOL CryptReleaseContext( [in] HCRYPTPROV hProv, [in] DWORD dwFlags );
Handle of a cryptographic service provider (CSP) created by a call to CryptAcquireContext.
Reserved for future use and must be zero. If dwFlags is not set to zero, this function returns FALSE but the CSP is released.
If the function succeeds, the return value is nonzero (TRUE).
If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError. Some possible error codes are listed in the following table.
||The CSP context specified by hProv is currently being used by another process.|
||One of the parameters specifies a handle that is not valid.|
||One of the parameters contains a value that is not valid. This is most often a pointer that is not valid.|
||The dwFlags parameter is nonzero.|
||The hProv parameter does not contain a valid context handle.|
After this function has been called, the CSP session is finished and all existing session keys and hash objects created by using the hProv handle are no longer valid. In practice, all of these objects should be destroyed with calls to CryptDestroyKey and CryptDestroyHash before CryptReleaseContext is called.
For an example that uses this function, see Example C Program: Creating and Hashing a Session Key.
|Minimum supported client||Windows XP [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2003 [desktop apps | UWP apps]|