修复大明Dynamsoft组件处理加载DLL异常问题(未设置DLL路径加载失败时,异常会被大明组件当作错误弹出警告框),改为统一设置路径后再加载。

This commit is contained in:
gb 2023-12-22 16:08:04 +08:00
parent ee19dba608
commit bfb5c45029
2 changed files with 5 additions and 4 deletions

View File

@ -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);

View File

@ -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))