CryptContextAddRef

Windows CE 3.0

This function is used to add one to the reference count on an HCRYPTPROV handle.

BOOL WINAPI CryptContextAddRef( 
HCRYPTPROV hProv,
DWORD *pdwReserved, 
DWORD dwFlags);

Parameters

hProv
[in] HCRYPTPROV handle for which the reference count is being incremented.
pdwReserved
[in] Reserved for future use; set to NULL.
dwFlags
[in] Specifies a bitmask of flags. This parameter is reserved for future use; set to 0.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError. Common values for GetLastError are described in the following table.

Value Description
ERROR_INVALID_PARAMETER One of the parameters contains an invalid value. This is most often an illegal pointer.

Remarks

CryptContextAddRef is used to increase the reference count on a HCRYPTPROV handle so that multiple calls to CryptReleaseContext are required to actually release the handle.

Example

HCRYPTPROV hProv = 0;

// Acquire a context handle
if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_SIG, 0)) {
 printf("Error %x during CryptAcquireContext!\n", GetLastError);
 return;
}

if (!CryptContextAddRef(&hProv, NULL, 0)) {
 printf("Error %x during CryptContextAddRef!\n", GetLastError);
 return;
}

...

// The first call to CryptReleaseContext will not release the provider handle
// since the reference count has been bumped up.
if (!CryptReleaseContext(hProv, 0)) {
 printf("Error %x during CryptReleaseContext!\n", GetLastError);
 return;
}

// Release the provider handle.
if (!CryptReleaseContext(hProv, 0)) {
 printf("Error %x during CryptReleaseContext!\n", GetLastError);
 return;
}

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 2.10 and later Wincrypt.h   Cryptapi.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CryptAcquireContext, CryptReleaseContext, HCRYPTPROV


 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.

Show: