Hardware Dev Center

DllInitialize routine

The system calls a kernel-mode DLL's DllInitialize routine immediately after the DLL is loaded.


NTSTATUS DllInitialize(
  _In_ PUNICODE_STRING RegistryPath


RegistryPath [in]

Pointer to a counted Unicode string specifying the path to the DLL's registry key, HKEY_LOCAL_MACHINE\CurrentControlSet\Services\DllName. DLL routines can use this key to store DLL-specific information. The buffer pointed to by RegistryPath is freed once DllInitialize exits. Therefore, if the DLL makes use of the key, DllInitialize must duplicate the key name.

Return value

The routine should return STATUS_SUCCESS if the DLL is successfully initialized, or the appropriate error code on failure. If the routine does not return STATUS_SUCCESS, the DLL is not loaded.


Export drivers must provide DllInitialize routines. You can use the DllInitialize routine to acquire or initialize resources required by other routines in the DLL. For more information about export drivers, see Creating Export Drivers.


Target platform



Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

See also




Send comments about this topic to Microsoft

© 2015 Microsoft