From bfb5c45029acd8e2ffd1dca0595d9c1a76eaf219 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Fri, 22 Dec 2023 16:08:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=A7=E6=98=8EDynamsoft?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=A4=84=E7=90=86=E5=8A=A0=E8=BD=BDDLL?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=EF=BC=88=E6=9C=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEDLL=E8=B7=AF=E5=BE=84=E5=8A=A0=E8=BD=BD=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=EF=BC=8C=E5=BC=82=E5=B8=B8=E4=BC=9A=E8=A2=AB?= =?UTF-8?q?=E5=A4=A7=E6=98=8E=E7=BB=84=E4=BB=B6=E5=BD=93=E4=BD=9C=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=BC=B9=E5=87=BA=E8=AD=A6=E5=91=8A=E6=A1=86=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=9F=E4=B8=80=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=90=8E=E5=86=8D=E5=8A=A0=E8=BD=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 4 ++-- twain/load_sane.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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))