summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-01-07 13:16:58 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-01-08 10:07:54 +0100
commitd0445802a86d67b55b5e333a4c815d062b5e6036 (patch)
tree019f6be915bd9bb0e00f7b23d869c4d03e0fdb45 /shell
parent563af8fd15aa37e75af8882cccbdf8914ebe8e61 (diff)
Use WindowsErrorString instead of FormatMessageW
Change-Id: I183f19f6abd4ca3f54d13533c8551deb09cd9458 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128118 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/source/win32/spsupp/spsuppHelper.cxx17
1 files changed, 5 insertions, 12 deletions
diff --git a/shell/source/win32/spsupp/spsuppHelper.cxx b/shell/source/win32/spsupp/spsuppHelper.cxx
index b5f6514decd6..af3509b87c8b 100644
--- a/shell/source/win32/spsupp/spsuppHelper.cxx
+++ b/shell/source/win32/spsupp/spsuppHelper.cxx
@@ -10,6 +10,7 @@
#include <prewin.h>
#include <postwin.h>
+#include <comphelper/windowserrorstring.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
#include <osl/file.hxx>
@@ -132,20 +133,12 @@ DWORD LOStart(const wchar_t* sModeArg, const wchar_t* sFilePath)
if (!CreateProcessW(nullptr, pCmdLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi))
{
DWORD dwError = GetLastError();
- wchar_t* sMsgBuf = nullptr;
- FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_IGNORE_INSERTS,
- nullptr, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- reinterpret_cast<LPWSTR>(&sMsgBuf), 0, nullptr);
-
- size_t nBufSize = wcslen(sMsgBuf) + 100;
- std::vector<wchar_t> sDisplayBuf(nBufSize);
- swprintf(sDisplayBuf.data(), nBufSize,
- L"Could not start LibreOffice. Error is 0x%08X:\n\n%s", dwError, sMsgBuf);
- HeapFree(GetProcessHeap(), 0, sMsgBuf);
+ const OUString sErrorMsg = "Could not start LibreOffice. Error is 0x"
+ + OUString::number(dwError, 16) + ":\n\n"
+ + WindowsErrorString(dwError);
// Report the error to user and return error
- MessageBoxW(nullptr, sDisplayBuf.data(), nullptr, MB_ICONERROR);
+ MessageBoxW(nullptr, o3tl::toW(sErrorMsg.getStr()), nullptr, MB_ICONERROR);
return dwError;
}
CloseHandle(pi.hProcess);