Expand Minimize

WdfDeviceCreateSymbolicLink method

[Applies to KMDF and UMDF]

The WdfDeviceCreateSymbolicLink method creates a symbolic link to a specified device.

Syntax


NTSTATUS WdfDeviceCreateSymbolicLink(
  [in]  WDFDEVICE Device,
  [in]  PCUNICODE_STRING SymbolicLinkName
);

Parameters

Device [in]

A handle to a framework device object.

SymbolicLinkName [in]

A pointer to a UNICODE_STRING structure that contains a user-visible name for the device.

Return value

If the operation succeeds, the WdfDeviceCreateSymbolicLink returns STATUS_SUCCCESS. Additional return values include:

Return codeDescription
STATUS_INSUFFICIENT_RESOURCES

The system cannot allocate space to store the device name.

 

The method might return other NTSTATUS values.

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

Remarks

If a driver creates a symbolic link for a device, applications can use the symbolic link name to access the device. Typically, instead of providing symbolic links, framework-based drivers provide device interfaces that applications can use to access their devices.

If the device is removed unexpectedly (surprise-removed), the framework removes the symbolic link to the device. The driver can then use the symbolic link name for a new instance of the device.

Examples

The following code example from a KMDF driver creates an MS-DOS device name that an application can use to access a device.


#define DOS_DEVICE_NAME  L"\\DosDevices\\MyDevice"
DECLARE_CONST_UNICODE_STRING(dosDeviceName, DOS_DEVICE_NAME);
NTSTATUS  status;

status = WdfDeviceCreateSymbolicLink(
                                     controlDevice,
                                     &dosDeviceName
                                     );
if (!NT_SUCCESS(status)) {
    goto Error;
}

A UMDF driver must provide a symbolic link name in the global DosDevices namespace, as the following code example illustrates.


#define DOS_DEVICE_NAME  L"\\DosDevices\\Global\\MyDevice"
DECLARE_CONST_UNICODE_STRING(dosDeviceName, DOS_DEVICE_NAME);
NTSTATUS  status;

status = WdfDeviceCreateSymbolicLink(
                                     controlDevice,
                                     &dosDeviceName
                                     );
if (!NT_SUCCESS(status)) {
    goto Error;
}

For information about global and local \DosDevices namespaces, see Local and Global MS-DOS Device Names.

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfdevice.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

UNICODE_STRING

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.