Implement qt_error_string for WinRT

Change-Id: I6049d67da0295aeec311b644ccedf8f27f86b1d1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
bb10
Oliver Wolff 2013-09-04 13:07:56 +02:00 committed by The Qt Project
parent f89d30aa34
commit 785eee0bf2
1 changed files with 14 additions and 1 deletions

View File

@ -2132,7 +2132,9 @@ QString qt_error_string(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
#ifdef Q_OS_WIN
#if defined(Q_OS_WIN)
// Retrieve the system error message for the last-error code.
# ifndef Q_OS_WINRT
wchar_t *string = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
@ -2143,6 +2145,17 @@ QString qt_error_string(int errorCode)
NULL);
ret = QString::fromWCharArray(string);
LocalFree((HLOCAL)string);
# else // !Q_OS_WINRT
__declspec(thread) static wchar_t errorString[4096];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errorString,
ARRAYSIZE(errorString),
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.");