Export (0) Print
Expand All

CryptReleaseContext (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function frees the handle to a cryptographic service provider (CSP) and the key container. At each call to this function, the reference count on the CSP is reduced by one. When the reference count reaches zero, the context is fully freed and it can no longer be used by any function in the application.

The application calls this function when it is finished using the CSP. After this function is called, the CSP handle specified by the hProv parameter is no longer valid; however, the function does not destroy either the key container or any key pairs.

BOOL WINAPI CryptReleaseContext( 
  HCRYPTPROV hProv,
  DWORD dwFlags
); 

Parameters

hProv
[in] HCRYPTPROV handle to a CSP created by a call to the CryptAcquireContext function.
dwFlags
[in] Reserved for future use and must be set to zero.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call the GetLastError function. The following table shows common values for the GetLastError function. The error values prefaced by NTE are generated by the particular CSP you are using.

ValueDescription
ERROR_BUSYThe CSP context specified by hProv is currently being used by another process.
ERROR_INVALID_HANDLEOne of the parameters specifies an invalid handle.
ERROR_INVALID_PARAMETEROne of the parameters contains an invalid value. This is most often an illegal pointer.
NTE_BAD_FLAGSThe dwFlags parameter is nonzero.
NTE_BAD_UIDThe hProv parameter does not contain a valid context handle.

Remarks

After calling this function, the session is over and all existing session keys and hash objects that were created by using the hProv handle become invalid. In practice, all of these objects should be destroyed with the CryptDestroyKey and CryptDestroyHash functions before calling the CryptReleaseContext function.

Example Code

See CryptHashSessionKey.

Requirements

OS Versions: Windows CE 2.10 and later.
Header: Wincrypt.h.
Link Library: Coredll.lib.

See Also

CryptAcquireContext | CryptDestroyKey | CryptDestroyHash


Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft