將目錄新增至進程 DLL 搜尋路徑。
語法
DLL_DIRECTORY_COOKIE AddDllDirectory(
[in] PCWSTR NewDirectory
);
參數
[in] NewDirectory
要新增至搜尋路徑的目錄的絕對路徑。 例如,若要將目錄 Dir2 新增至進程 DLL 搜尋路徑,請指定 \Dir2。 如需路徑的詳細資訊,請參閱 命名檔案、路徑和命名空間。
返回值
如果函式成功,傳回值是不透明指標,可以傳遞至 RemoveDllDirectory ,以從進程 DLL 搜尋路徑移除 DLL。
如果函式失敗,傳回值為零。 若要取得擴充的錯誤資訊,請呼叫 GetLastError。
備註
AddDllDirectory 函式可用來將任何絕對路徑新增至搜尋 DLL 的目錄集。 如果先使用 LOAD_LIBRARY_SEARCH_USER_DIRS 呼叫 SetDefaultDllDirectories,則會將 AddDllDirectory 指定的目錄新增至進程 DLL 搜尋路徑。 否則,使用 AddDllDirectory 函式指定的目錄只會用於指定LOAD_LIBRARY_SEARCH_USER_DIRS的 LoadLibraryEx 函式呼叫。
如果 使用 AddDllDirectory 將多個目錄新增至進程 DLL 搜尋路徑,則未指定搜尋這些目錄的順序。
若要移除使用 AddDllDirectory 新增的目錄,請使用 RemoveDllDirectory 函式。
Windows 7、Windows Server 2008 R2、Windows Vista 和 Windows Server 2008: 若要在應用程式中使用此函式,請呼叫 GetProcAddress 以從 Kernel32.dll擷取函式的位址。 KB2533623 必須安裝在目標平台上。
需求
| Requirement | 價值觀 |
|---|---|
| 最低支援的用戶端 | Windows 8 [僅限傳統型應用程式],KB2533623 Windows 7、Windows Server 2008 R2、Windows Vista 和 Windows Server 2008 |
| 支援的最低伺服器 | Windows Server 2012 [僅限傳統型應用程式] |
| 目標平臺 | 窗戶 |
| Header | libloaderapi.h (包括 Windows.h) |
| Library | 內核32。圖書館 |
| DLL | Kernel32.dll |