2015-08-13 13:22:28 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_COMPHELPER_WINDOWSERRORSTRING_HXX
|
|
|
|
#define INCLUDED_COMPHELPER_WINDOWSERRORSTRING_HXX
|
|
|
|
|
|
|
|
#include <prewin.h>
|
|
|
|
#include <postwin.h>
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
inline OUString WindowsErrorString(DWORD nErrorCode)
|
|
|
|
{
|
|
|
|
LPWSTR pMsgBuf;
|
|
|
|
|
|
|
|
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
2016-10-14 16:58:25 +02:00
|
|
|
nullptr,
|
2015-08-13 13:22:28 +03:00
|
|
|
nErrorCode,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
2016-10-14 16:58:25 +02:00
|
|
|
reinterpret_cast<LPWSTR>(&pMsgBuf),
|
2015-08-13 13:22:28 +03:00
|
|
|
0,
|
2016-10-14 16:58:25 +02:00
|
|
|
nullptr) == 0)
|
2015-08-13 13:22:28 +03:00
|
|
|
return OUString::number(nErrorCode, 16);
|
|
|
|
|
2017-09-26 11:28:57 +03:00
|
|
|
OUString result(SAL_U(pMsgBuf));
|
2017-04-26 17:36:57 +02:00
|
|
|
result.endsWith("\r\n", &result);
|
2015-08-13 13:22:28 +03:00
|
|
|
|
|
|
|
LocalFree(pMsgBuf);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|