Expand Minimize

WdfDeviceInitAssignName method

[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

DeviceInit [in]

A pointer to a WDFDEVICE_INIT structure.

DeviceName [in, optional]

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 codeDescription
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

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, ControlDeviceInitAPI, DeviceInitAPI, DriverCreate, InitFreeDeviceCallback, InitFreeDeviceCreate, InitFreeNull, KmdfIrql, KmdfIrql2, PdoDeviceInitAPI, PdoInitFreeDeviceCallback, PdoInitFreeDeviceCreate

See also

WdfDeviceRetrieveDeviceName

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.