diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-09-30 11:29:46 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-09-30 12:23:34 +0200 |
commit | 37b81dd54a915223780a6b5efa54ce45db332604 (patch) | |
tree | a05c43825b52ea2eb22e8aa5f98aa0fb32236eea /extensions/source | |
parent | 528cc99c57fa90a08c92e8bf654a0efee8ecf39f (diff) |
twain32shim: Windows directory might not be in DLL search path sometimes
So try the full path to TWAIN_32.DLL if first try failed.
Change-Id: I9ad262c91ebc7b3df63fbec3ffe34595ffd78c75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103669
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'extensions/source')
-rw-r--r-- | extensions/source/scanner/twain32shim.cxx | 15 | ||||
-rw-r--r-- | extensions/source/scanner/twain32shim.hxx | 1 |
2 files changed, 15 insertions, 1 deletions
diff --git a/extensions/source/scanner/twain32shim.cxx b/extensions/source/scanner/twain32shim.cxx index 8ccd2bd1b32d..30cbba8558e4 100644 --- a/extensions/source/scanner/twain32shim.cxx +++ b/extensions/source/scanner/twain32shim.cxx @@ -254,7 +254,20 @@ void ImpTwain::ImplOpenSourceManager() { if (TWAINState::DSMunloaded == m_nCurState) { - if ((m_hMod = LoadLibraryW(L"TWAIN_32.DLL"))) + m_hMod = LoadLibraryW(L"TWAIN_32.DLL"); + if (!m_hMod) + { + // Windows directory might not be in DLL search path sometimes, so try the full path + PWSTR sPath; + if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Windows, 0, nullptr, &sPath))) + { + std::wstring sPathAndFile = sPath; + CoTaskMemFree(sPath); + sPathAndFile += L"\\TWAIN_32.DLL"; + m_hMod = LoadLibraryW(sPathAndFile.c_str()); + } + } + if (m_hMod) { m_nCurState = TWAINState::DSMloaded; diff --git a/extensions/source/scanner/twain32shim.hxx b/extensions/source/scanner/twain32shim.hxx index 9f42f0a4d5dc..c9e87ee8bb57 100644 --- a/extensions/source/scanner/twain32shim.hxx +++ b/extensions/source/scanner/twain32shim.hxx @@ -11,6 +11,7 @@ #pragma once #include <prewin.h> +#include <Shlobj.h> #include <postwin.h> #include <exception> #include <string> |