BCryptQueryContextConfiguration function (bcrypt.h)

[BCryptQueryContextConfiguration is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]

The BCryptQueryContextConfiguration function retrieves the current configuration for the specified CNG context.


NTSTATUS BCryptQueryContextConfiguration(
  [in]      ULONG                 dwTable,
  [in]      LPCWSTR               pszContext,
  [in, out] ULONG                 *pcbBuffer,
  [in, out] PCRYPT_CONTEXT_CONFIG *ppBuffer


[in] dwTable

Identifies the configuration table that the context exists in. This can be one of the following values.

Value Meaning
The context exists in the local-machine configuration table.
This value is not available for use.

[in] pszContext

A pointer to a null-terminated Unicode string that contains the identifier of the context to obtain the configuration information for.

[in, out] pcbBuffer

The address of a ULONG variable that, on entry, contains the size, in bytes, of the buffer pointed to by ppBuffer. If this size is not large enough to hold the context information, this function will fail with STATUS_BUFFER_TOO_SMALL.

After this function returns, this variable contains the number of bytes that were copied to the ppBuffer buffer.

[in, out] ppBuffer

The address of a pointer to a CRYPT_CONTEXT_CONFIG structure that receives the context configuration information retrieved by this function. The value pointed to by the pcbBuffer parameter contains the size of this buffer.

If the value pointed to by this parameter is NULL, this function will allocate the required memory. This memory must be freed when it is no longer needed by passing this pointer to the BCryptFreeBuffer function.

If this parameter is NULL, this function will place the required size, in bytes, in the variable pointed to by the pcbBuffer parameter and return STATUS_BUFFER_TOO_SMALL.

For more information on the usage of this parameter, see Remarks.

Return value

Returns a status code that indicates the success or failure of the function.

Possible return codes include, but are not limited to, the following.

Return code Description
The function was successful.
The ppBuffer parameter is not NULL, and the value pointed to by the pcbBuffer parameter is not large enough to hold the set of contexts.
One or more parameters are not valid.
A memory allocation failure occurred.
The specified context could not be found.


Each context has only one set of configuration information, so although the ppBuffer parameter appears to be a used as an array, this function treats this as an array with only one element. The following example helps clarify how this parameter is used.

// Get the configuration information for the context.
ULONG uSize = sizeof(config);
PCRYPT_CONTEXT_CONFIG pConfig = &config;
status = BCryptQueryContextConfiguration(

BCryptQueryContextConfiguration can be called only in user mode.


Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header bcrypt.h
Library Bcrypt.lib
DLL Bcrypt.dll