diff options
-rw-r--r-- | xmlsecurity/Library_xmlsecurity.mk | 2 | ||||
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 23 |
2 files changed, 23 insertions, 2 deletions
diff --git a/xmlsecurity/Library_xmlsecurity.mk b/xmlsecurity/Library_xmlsecurity.mk index 9a65dd2152a9..5a80e6e17591 100644 --- a/xmlsecurity/Library_xmlsecurity.mk +++ b/xmlsecurity/Library_xmlsecurity.mk @@ -83,6 +83,8 @@ $(eval $(call gb_Library_add_defs,xmlsecurity,\ )) $(eval $(call gb_Library_use_system_win32_libs,xmlsecurity,\ crypt32 \ + Ole32 \ + Shell32 \ )) else ifneq (,$(filter DESKTOP,$(BUILD_TYPE))$(filter ANDROID,$(OS))) diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 032171928c88..67545e3bb561 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -59,6 +59,12 @@ #include <vcl/svapp.hxx> #include <unotools/configitem.hxx> +#ifdef _WIN32 +#include <o3tl/char16_t2wchar_t.hxx> +#include <prewin.h> +#include <Shlobj.h> +#endif + using namespace comphelper; using namespace css::security; using namespace css::uno; @@ -457,15 +463,28 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, weld::Button&, void) OUString("GNU\\GnuPG\\bin\\kleopatra.exe"), OUString("GNU\\GnuPG\\bin\\launch-gpa.exe"), OUString("GNU\\GnuPG\\bin\\gpa.exe") }; - const char* const cPath = "C:\\Program Files (x86)"; + static const OUString aPath = [] { + OUString sRet; + PWSTR sPath = nullptr; + HRESULT hr + = SHGetKnownFolderPath(FOLDERID_ProgramFilesX86, KF_FLAG_DEFAULT, nullptr, &sPath); + if (SUCCEEDED(hr)) + { + sRet = o3tl::toU(sPath); + CoTaskMemFree(sPath); + } + return sRet; + }(); + if (aPath.isEmpty()) + return; #else const OUString aGUIServers[] = { OUString("kleopatra"), OUString("seahorse"), OUString("gpa"), OUString("kgpg") }; const char* cPath = getenv("PATH"); if (!cPath) return; + OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding()); #endif - OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding()); OUString sFoundGUIServer, sExecutable; for ( auto const &rServer : aGUIServers ) |