函数参考


_WinAPI_SetDllDirectory

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

#Include <WinAPIEx.au3>
_WinAPI_SetDllDirectory ( $sPath )

参数

$sPath 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.

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

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 $sPath 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.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

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

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

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

_WinAPI_FreeLibrary($hModule)