WdfRegistryQueryString method

[Applies to KMDF and UMDF]

The WdfRegistryQueryString method retrieves the string data that is currently assigned to a specified registry string value and assigns the string to a specified framework string object.

Syntax


NTSTATUS WdfRegistryQueryString(
  [in]  WDFKEY Key,
  [in]  PCUNICODE_STRING ValueName,
  [in]  WDFSTRING String
);

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 name for the registry value.

String [in]

A handle to a framework string object. The framework will assign the registry value's string data to this object.

Return value

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

Return codeDescription
STATUS_INVALID_DEVICE_REQUEST

WdfRegistryQueryString was not called at IRQL = PASSIVE_LEVEL.

STATUS_INVALID_PARAMETER

An invalid parameter was specified.

STATUS_INSUFFICIENT_RESOURCES

There was insufficient memory to complete the operation.

STATUS_ACCESS_DENIED

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

STATUS_OBJECT_TYPE_MISMATCH

The data type of the registry value that the ValueName parameter specified was not REG_SZ.

 

For a list of other return values that the WdfRegistryQueryString method might return, see Framework Object Creation Errors.

This method also might return other NTSTATUS values.

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

Remarks

To obtain a string from a string object, your driver can call WdfStringGetUnicodeString.

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

Examples

The following code example creates a string object, retrieves string data from a registry key, and obtains the string data from the string object.


UNICODE_STRING str;
WDFSTRING string;
NTSTATUS status;
DECLARE_CONST_UNICODE_STRING(valueName, STRING_VALUE_NAME);

status = WdfStringCreate(
                         NULL,
                         WDF_NO_OBJECT_ATTRIBUTES,
                         &string
                         );
if (NT_SUCCESS(status)) {
    status = WdfRegistryQueryString(
                                    Key, 
                                    &valueName,
                                    string
                                    );
    if (NT_SUCCESS(status)) {
        WdfStringGetUnicodeString(
                                  string,
                                  &str
                                  );
    }
}

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

UNICODE_STRING
WdfRegistryQueryMemory
WdfRegistryQueryMultiString
WdfRegistryQueryUnicodeString
WdfRegistryQueryULong
WdfRegistryQueryValue
WdfStringCreate
WdfStringGetUnicodeString

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.