WdfRegistryAssignUnicodeString function

[Applies to KMDF and UMDF]

The WdfRegistryAssignUnicodeString method assigns a specified Unicode string to a specified value name in the registry.

Syntax

NTSTATUS WdfRegistryAssignUnicodeString(
  _In_ WDFKEY           Key,
  _In_ PCUNICODE_STRING ValueName,
  _In_ PCUNICODE_STRING Value
);

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.

Value

A pointer to a UNICODE_STRING structure that contains the string to be assigned to the value name that ValueName specifies.

Return Value

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

Return code Description
STATUS_INVALID_DEVICE_REQUEST
WdfRegistryAssignUnicodeString 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_SET_VALUE access.
STATUS_INSUFFICIENT_RESOURCES
There was insufficient memory to complete the operation.

This method also might return other NTSTATUS values.

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

Remarks

If the string that the Value parameter specifies is not NULL-terminated, the framework adds a NULL character when copying the string to the registry.

If the value name that the ValueName parameter specifies already exists, WdfRegistryAssignUnicodeString updates the value's data.

The framework sets the value's data type to REG_SZ.

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

Examples

The following code example assigns a Unicode string "String1" to the ValueName value, under a specified registry key.

UNICODE_STRING ustring1, valueName;
NTSTATUS status;

RtlInitUnicodeString(
                     &ustring1,
                     L"String1"
                     );
RtlInitUnicodeString(
                     &valueName,
                     L"ValueName"
                     );

status = WdfRegistryAssignUnicodeString(
                                        Key,
                                        &valueName,
                                        &string1
                                        );

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

WdfRegistryAssignValue

RtlInitUnicodeString

WdfRegistryAssignString

UNICODE_STRING

WdfRegistryAssignULong

WdfRegistryAssignMultiString

WdfRegistryAssignMemory

Send comments about this topic to Microsoft