WdfRegistryQueryMultiString function

[Applies to KMDF and UMDF]

The WdfRegistryQueryMultiString method retrieves the strings that are currently assigned to a specified multi-string registry value, creates a framework string object for each string, and adds each string object to a specified object collection.

Syntax

NTSTATUS WdfRegistryQueryMultiString(
  _In_     WDFKEY                 Key,
  _In_     PCUNICODE_STRING       ValueName,
  _In_opt_ PWDF_OBJECT_ATTRIBUTES StringsAttributes,
  _In_     WDFCOLLECTION          Collection
);

Parameters

Key

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

ValueName

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

StringsAttributes

A pointer to a WDF_OBJECT_ATTRIBUTES structure that contains object attributes for each new string object. This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

Collection

A handle to a driver-supplied framework collection object.

Return Value

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

Return code Description
STATUS_INVALID_DEVICE_REQUEST
WdfRegistryQueryMultiString was not called at IRQL = PASSIVE_LEVEL.
STATUS_INVALID_PARAMETER
An invalid parameter was specified.
STATUS_INSUFFICIENT_RESOURCES
A string object could not be allocated.
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_MULTI_SZ.
STATUS_OBJECT_NAME_NOT_FOUND
The registry value was not available.
STATUS_RESOURCE_DATA_NOT_FOUND
The registry value exists under the specified key, but is empty.

For a list of other return values that the WdfRegistryQueryMultiString 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

Before your driver calls WdfRegistryQueryMultiString, it must call WdfCollectionCreate to create a collection object.

After WdfRegistryQueryMultiString returns, the driver can call WdfCollectionGetCount to obtain the number of retrieved strings and WdfCollectionGetItem to obtain string objects from the collection.

If the collection contains objects before the driver calls the WdfRegistryQueryMultiString method, the method does not remove those objects or change their index values. The new objects are appended to the end of the collection.

To obtain a string from a string object, the 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 collection object, initializes a WDF_OBJECT_ATTRIBUTES structure so that the collection object will be the parent of all of the string objects that the framework creates for the collection, and retrieves the strings from a multi-string registry value. Finally, the example obtains the number of string objects that the framework added to the collection.

WDF_OBJECT_ATTRIBUTES stringAttributes;
WDFCOLLECTION col;
NTSTATUS status;
ULONG count;
DECLARE_CONST_UNICODE_STRING(valueMultiSz, VALUE_MULTI_SZ);

status = WdfCollectionCreate(
                             NULL,
                             &col
                             );
ASSERT(NT_SUCCESS(status));

WDF_OBJECT_ATTRIBUTES_INIT(&stringAttributes);
stringAttributes.ParentObject = col;

status = WdfRegistryQueryMultiString(
                                     Key,
                                     &valueMultiSzEmpty,
                                     &stringAttributes,
                                     col
                                     );

count = WdfCollectionGetCount(col);

Requirements

   
Target Platform Universal
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

WdfStringGetUnicodeString

WdfCollectionCreate

WdfRegistryQueryString

WdfCollectionGetCount

WdfRegistryQueryUnicodeString

WdfRegistryQueryMemory

WdfRegistryQueryULong

WdfCollectionGetItem

WdfRegistryQueryMemory

WdfRegistryQueryULong

Send comments about this topic to Microsoft