WdfDeviceInitAssignName function (wdfdevice.h)

[Applies to KMDF only]

The WdfDeviceInitAssignName method assigns a device name to a device's device object.

Syntax

NTSTATUS WdfDeviceInitAssignName(
  [in]           PWDFDEVICE_INIT  DeviceInit,
  [in, optional] PCUNICODE_STRING DeviceName
);

Parameters

[in] DeviceInit

A pointer to a WDFDEVICE_INIT structure.

[in, optional] DeviceName

A pointer to a UNICODE_STRING structure that represents the device name.

Return value

If WdfDeviceInitAssignName encounters no errors it returns STATUS_SUCCESS. Additional return values include:

Return code Description
STATUS_INSUFFICIENT_RESOURCES
The system cannot allocate space to store the device name.

Remarks

If a driver calls WdfDeviceInitAssignName, it must do so before it calls WdfDeviceCreate.

If a driver calls WdfDeviceInitAssignName to assign a name, the driver can subsequently call WdfDeviceInitAssignName with a NULL DeviceName parameter to clear the device name. If the device name is NULL and the device object requires a name (because it represents a PDO or a control device), the operating system will create a name.

For more information about naming device objects, see Controlling Device Access in Framework-Based Drivers.

For more information about calling WdfDeviceCreate, see Creating a Framework Device Object.

Examples

The following code example assigns an NT device name to a device.

DECLARE_CONST_UNICODE_STRING(MyDeviceName, L"\\Device\\Ramdisk") ;
status = WdfDeviceInitAssignName(
                                 DeviceInit,
                                 &MyDeviceName
                                 );
if (!NT_SUCCESS(status)) {
    return status;
}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Header wdfdevice.h (include Wdf.h)
Library Wdf01000.sys (see Framework Library Versioning.)
IRQL PASSIVE_LEVEL
DDI compliance rules ChildDeviceInitAPI(kmdf), ControlDeviceInitAPI(kmdf), DeviceInitAPI(kmdf), DriverCreate(kmdf), InitFreeDeviceCallback(kmdf), InitFreeDeviceCreate(kmdf), InitFreeNull(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), PdoDeviceInitAPI(kmdf), PdoInitFreeDeviceCallback(kmdf), PdoInitFreeDeviceCreate(kmdf)

See also

WdfDeviceRetrieveDeviceName