WdfRegistryQueryValue method

[Applies to KMDF and UMDF]

The WdfRegistryQueryValue method retrieves the data that is currently assigned to a specified registry value.

Syntax


NTSTATUS WdfRegistryQueryValue(
  [in]             WDFKEY Key,
  [in]             PCUNICODE_STRING ValueName,
  [in]             ULONG ValueLength,
  [out, optional]  PVOID Value,
  [out, optional]  PULONG ValueLengthQueried,
  [out, optional]  PULONG ValueType
);

Parameters

Key [in]

A handle to a registry-key object that represents an opened registry key.

ValueName [in]

A pointer to a UNICODE_STRING structure that contains a value name.

ValueLength [in]

The length, in bytes, of the buffer that Value points to.

Value [out, optional]

A pointer to a driver-allocated buffer that receives the registry value's data. If this pointer is NULL, WdfRegistryQueryValue retrieves the data length but not the data.

ValueLengthQueried [out, optional]

A pointer to a location that receives the registry value's data length. This pointer is optional and can be NULL.

ValueType [out, optional]

A pointer to a location that receives the registry value's data type. For a list of data type values, see the Type member of KEY_VALUE_BASIC_INFORMATION. This pointer is optional and can be NULL.

Return value

WdfRegistryQueryValue returns STATUS_SUCCESS if the operation succeeds. Otherwise, the method might return one of the following values:

Return codeDescription
STATUS_INVALID_DEVICE_REQUEST

WdfRegistryQueryValue was not called at IRQL = PASSIVE_LEVEL.

STATUS_INVALID_PARAMETER

An invalid parameter was specified.

STATUS_ACCESS_DENIED

The driver did not open the registry key with KEY_QUERY_VALUE, KEY_READ, or KEY_ALL_ACCESS access.

STATUS_BUFFER_OVERFLOW

The buffer that the Value parameter points to is too small, and only partial data has been written to the buffer.

STATUS_BUFFER_OVERFLOW

The Value buffer is too small, and no data has been written to the buffer.

STATUS_OBJECT_NAME_NOT_FOUND

The registry value was not available.

 

This method also might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

For more information about registry-key objects, see Using the Registry in Framework-Based Drivers.

Examples

The following code example opens a device's hardware key and retrieves the data that is assigned to the NumberOfToasters value, which is stored under the device's hardware key.


WCHAR  comPort[FM_COM_PORT_STRING_LENGTH];
ULONG  length;
NTSTATUS  status;
ULONG  length, valueType, value;
DECLARE_CONST_UNICODE_STRING(valueName, L"NumberOfToasters");
WDFKEY  hKey;

status = WdfDeviceOpenRegistryKey(
                                  Device,
                                  PLUGPLAY_REGKEY_DEVICE,
                                  KEY_QUERY_VALUE,
                                  NULL, 
                                  &hKey
                                  );
if (!NT_SUCCESS (status)) {
    goto Error;
}
status = WdfRegistryQueryValue(
                               hKey,
                               &valueName,
                               sizeof(ULONG),
                               &value,
                               &length,
                               &valueType
                               );

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfregistry.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

KEY_VALUE_BASIC_INFORMATION
UNICODE_STRING
WdfDeviceOpenRegistryKey
WdfRegistryQueryMemory
WdfRegistryQueryMultiString
WdfRegistryQueryString
WdfRegistryQueryULong
WdfRegistryQueryUnicodeString

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft