Function Reference


_WinAPI_SetDllDirectory

Adds a directory to the search path used to locate DLLs for the application

#include <WinAPISys.au3>
_WinAPI_SetDllDirectory ( [$sDirPath = Default] )

Parameters

$sDirPath [optional] The directory to be added to the search path. If this parameter is an empty string (""), the call
removes the current directory from the default DLL search order. If this parameter is not specified,
the function restores the default search order (Default).

Return Value

Success: True.
Failure: False, call _WinAPI_GetLastError() to get extended error information.

Remarks

This function affects all subsequent calls to the _WinAPI_LoadLibrary() and _WinAPI_LoadLibraryEx() functions.
It also effectively disables safe DLL search mode while the specified directory is in the search path.

After calling _WinAPI_SetDllDirectory(), the DLL search path is:

1. The directory from which the application was loaded.
2. The directory specified by the $sFilePath parameter.
3. The system directory.
4. The 16-bit system directory.
5. The Windows directory.
6. The directories that are listed in the PATH environment variable.

Related

_WinAPI_LoadLibrary, _WinAPI_LoadLibraryEx

See Also

Search SetDllDirectory in MSDN Library.

Example

#include <WinAPIRes.au3>
#include <WinAPISys.au3>

If Not _WinAPI_SetDllDirectory(@ScriptDir & '\Extras') Then
        Exit
EndIf

Local $hModule = _WinAPI_LoadLibraryEx('Resources.dll', $LOAD_LIBRARY_AS_DATAFILE)

ConsoleWrite('Path:   ' & _WinAPI_GetDllDirectory() & @CRLF)
ConsoleWrite('Module: ' & $hModule & @CRLF)

_WinAPI_FreeLibrary($hModule)