extensions/Executable_twain32shim.mk      |    1 +
 extensions/source/scanner/twain32shim.cxx |   15 ++++++++++++++-
 extensions/source/scanner/twain32shim.hxx |    1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 37b81dd54a915223780a6b5efa54ce45db332604
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Sep 30 11:29:46 2020 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Sep 30 12:23:34 2020 +0200

    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.kagan...@collabora.com>

diff --git a/extensions/Executable_twain32shim.mk 
b/extensions/Executable_twain32shim.mk
index 3ac3ce8d43ed..f063f7d6e3b4 100644
--- a/extensions/Executable_twain32shim.mk
+++ b/extensions/Executable_twain32shim.mk
@@ -37,6 +37,7 @@ $(eval $(call 
gb_Executable_add_exception_objects,twain32shim,\
 ))
 
 $(eval $(call gb_Executable_use_system_win32_libs,twain32shim,\
+    Ole32 \
     shell32 \
 ))
 
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>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to