From f922dc165c61faeba39441595cb67dcf088ee8c8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 15 Aug 2016 11:16:58 +0200 Subject: idc: Search %PATH% when loading libraries Call LoadLibraryEx() with flags=0 in addition to get the LoadLibrary() behavior (search %PATH%). Amends change 824df695ad99d6096c2744bd476f75822cee1323. Task-number: QTBUG-55283 Change-Id: Ib10eea9f71677c877f5316b45562ed48d1cc31cb Reviewed-by: Fredrik Orderud Reviewed-by: Oliver Wolff --- src/tools/idc/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tools/idc/main.cpp b/src/tools/idc/main.cpp index 61e51e4..50610ac 100644 --- a/src/tools/idc/main.cpp +++ b/src/tools/idc/main.cpp @@ -181,12 +181,17 @@ static bool attachTypeLibrary(const QString &applicationName, int resource, cons static HMODULE loadLibraryQt(const QString &input) { + const wchar_t *inputC = reinterpret_cast(input.utf16()); if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA) - return LoadLibrary(reinterpret_cast(input.utf16())); // fallback for Windows XP and older + return LoadLibrary(inputC); // fallback for Windows XP and older // Load DLL with the folder containing the DLL temporarily added to the search path when loading dependencies - return LoadLibraryEx(reinterpret_cast(input.utf16()), NULL, - LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + HMODULE result = + LoadLibraryEx(inputC, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + // If that fails, call with flags=0 to get LoadLibrary() behavior (search %PATH%). + if (!result) + result = LoadLibraryEx(inputC, NULL, 0); + return result; } static bool registerServer(const QString &input) -- cgit v1.2.3