The same logic works in KMDF, there is no functional difference here between kmdf and wdm in how to format a string
ULONG g_Count = 0;
#define SYMLINK_NAME L"\DosDevices\Driver"
// support for 1000 links, XXX is a placeholder for 0-999
// this actually gives you one extra character b/c sizeof(string constant) will include the null in the size
#define SYMLINK_BUFFER_LENGTH (sizeof(SYMLINK_NAME L"XXX")/sizeof(WCHAR))
AddDevice()
{
DECLARE_UNICODE_STRING_SIZE(symlink, SYMLINK_BUFFER_LENGTH);
NTSTATUS status = RtlUnicodeStringPrintf(&symlink, SYMLINK_NAME L"%d", InterlockedIncrement(&g_Count));
…
}
You could make above code allocate the string buffer to make sure you can support an infinite number of links if you want to make your life more complicated…
D
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Thursday, January 24, 2008 5:17 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfDeviceCreateSymbolicLink
This is probably a dumb question but how can I create multiple symbolic links. I only need one per device but I want multiple devices.
Right now I’m using:
DECLARE_CONST_UNICODE_STRING(dosDeviceName, L"\DosDevices\Driver0");
and
status = WdfDeviceCreateSymbolicLink(device, &dosDeviceName);
How can I make it such that every call to EvtDeviceAdd uses a different index on the end of Driver - ‘n’? I’ve seen a version in a WDM driver using a static variable for the device number but I can’t get that to work in WDF.
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer