Windows Driver Kit: Kernel-Mode Driver Framework
WdfDeviceInitAssignName

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

NTSTATUS
  WdfDeviceInitAssignName(
    IN PWDFDEVICE_INIT  DeviceInit,
    IN PCUNICODE_STRING  DeviceName
    );

Parameters

DeviceInit
A pointer to a WDFDEVICE_INIT structure.
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:

STATUS_INSUFFICIENT_RESOURCES, if the system cannot allocate space to store the device name.

Comments

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 object's see Controlling Device Access in Framework-Based Drivers.

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

Example

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

Versions: The WdfDeviceInitAssignName method is available in version 1.0 and later versions of KMDF.

IRQL: PASSIVE_LEVEL

Headers: Declared in wdfdevice.h. Include wdf.h.

See Also

WdfDeviceRetrieveDeviceName


Send feedback on this topic
Built on October 01, 2009
Page view tracker