summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qsystemerror.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@digia.com>2013-09-04 13:10:15 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-16 00:14:00 +0200
commit134a020e2a3314ad2ddcfe22741e60ba251138dc (patch)
treee4db99ca53c6bea9472f7a8a2aa8468370b97de5 /src/corelib/kernel/qsystemerror.cpp
parentcfc7cc39f971779729b83a2e4d39a4cb48ff20a3 (diff)
Implement windowsErrorString for WinRT
FORMAT_MESSAGE_ALLOCATE_BUFFER isn't available for WinRT Change-Id: Ib9cf2a11a4e84f3ff010665bd53b4ffb0d0bfcce Reviewed-by: Andrew Knight <andrew.knight@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib/kernel/qsystemerror.cpp')
-rw-r--r--src/corelib/kernel/qsystemerror.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 8d375f1fb3..e22ea75e15 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -84,6 +84,7 @@ namespace {
static QString windowsErrorString(int errorCode)
{
QString ret;
+#ifndef Q_OS_WINRT
wchar_t *string = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
@@ -94,6 +95,17 @@ static QString windowsErrorString(int errorCode)
NULL);
ret = QString::fromWCharArray(string);
LocalFree((HLOCAL)string);
+#else
+ wchar_t errorString[1024];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPWSTR)&errorString,
+ sizeof(errorString)/sizeof(wchar_t),
+ NULL);
+ ret = QString::fromWCharArray(errorString);
+#endif // Q_OS_WINRT
if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
ret = QString::fromLatin1("The specified module could not be found.");