diff --git a/sane/scanner.cpp b/sane/scanner.cpp index d46ad25..6734611 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -369,8 +369,8 @@ namespace callback static int load_dll(const char* path_dll, HMODULE* dll) { - HMODULE h = LoadLibraryA(path_dll); - int ret = GetLastError(); + HMODULE h = NULL; // LoadLibraryA(path_dll); // 3rd APP like Dynamsoft will treat the exception, so we force to SetDllDirectoryW first and load later + int ret = 0; // GetLastError(); char info[128] = { 0 }; sprintf_s(info, _countof(info) - 1, " = %d\r\n", ret); diff --git a/twain/load_sane.cpp b/twain/load_sane.cpp index c9327a1..76004d6 100644 --- a/twain/load_sane.cpp +++ b/twain/load_sane.cpp @@ -108,10 +108,11 @@ namespace load_sane_util } static int load_dll(const wchar_t* path_dll, HMODULE* dll) { - HMODULE h = LoadLibraryW(path_dll); - int ret = GetLastError(); + HMODULE h = NULL; // LoadLibraryW(path_dll); // 3rd APP like Dynamsoft will treat the exception, so we force to SetDllDirectoryW first and load later + int ret = 0; // GetLastError(); wchar_t info[128] = { 0 }; + // SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE); swprintf_s(info, _countof(info) - 1, L" = %d\r\n", ret); OutputDebugStringW((L"[TWAIN]Load: " + std::wstring(path_dll) + info).c_str()); if (!h && (ret == ERROR_MOD_NOT_FOUND || ret == ERROR_BAD_EXE_FORMAT || ret == 0))