GetDllDirectoryA function (winbase.h)

Retrieves the application-specific portion of the search path used to locate DLLs for the application.

Syntax

DWORD GetDllDirectoryA(
  [in]  DWORD nBufferLength,
  [out] LPSTR lpBuffer
);

Parameters

[in] nBufferLength

The size of the output buffer, in characters.

[out] lpBuffer

A pointer to a buffer that receives the application-specific portion of the search path.

Return value

If the function succeeds, the return value is the length of the string copied to lpBuffer, in characters, not including the terminating null character. If the return value is greater than nBufferLength, it specifies the size of the buffer required for the path.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

To compile an application that uses this function, define _WIN32_WINNT as 0x0502 or later. For more information, see Using the Windows Headers.

Note

The winbase.h header defines GetDllDirectory as an alias that automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows Vista, Windows XP with SP1 [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

Dynamic-Link Library Search Order

SetDllDirectory