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.
Syntax
BOOL CryptReleaseContext(
[in] HCRYPTPROV hProv,
[in] DWORD dwFlags
);
Parameters
[in] hProv
Handle of a cryptographic service provider (CSP) created by a call to CryptAcquireContext.
[in] dwFlags
Reserved for future use and must be zero. If dwFlags is not set to zero, this function returns FALSE but the CSP is released.
Return value
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.
Return code | Description |
---|---|
|
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. |
Remarks
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.
Examples
For an example that uses this function, see Example C Program: Creating and Hashing a Session Key.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2003 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | wincrypt.h |
Library | Advapi32.lib |
DLL | Advapi32.dll |