// wdfdevice.h
NTSTATUS WdfDeviceInitAssignName(
[in] PWDFDEVICE_INIT DeviceInit,
[in, optional] PCUNICODE_STRING DeviceName
);
View the official Windows Driver Kit DDI reference
No description available.
[Applies to KMDF only]
The WdfDeviceInitAssignName method assigns a device name to a device's device object.
DeviceInit
[in]A pointer to a WDFDEVICE_INIT structure.
DeviceName
[in, optional]A pointer to a UNICODE_STRING structure that represents the device name.
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. |
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.
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;
}