diff options
author | Friedemann Kleint <qtc-committer@nokia.com> | 2009-03-03 14:01:58 +0100 |
---|---|---|
committer | Friedemann Kleint <qtc-committer@nokia.com> | 2009-03-03 14:08:32 +0100 |
commit | a26d745c79d9d7801357f3dfb42c09d1e5f50c6f (patch) | |
tree | 94de2c205f426fbd772ed5b510d8503761aedad3 /src/libs/utils/winutils.cpp | |
parent | 3d6f7de90929971a25fcab12ad569b6bf6db92de (diff) |
m.txt
Diffstat (limited to 'src/libs/utils/winutils.cpp')
-rw-r--r-- | src/libs/utils/winutils.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/libs/utils/winutils.cpp b/src/libs/utils/winutils.cpp new file mode 100644 index 00000000000..3fd789707e6 --- /dev/null +++ b/src/libs/utils/winutils.cpp @@ -0,0 +1,56 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ + +#include "winutils.h" +#include <windows.h> + +#include <QtCore/QString> + +namespace Core { +namespace Utils { + +QWORKBENCH_UTILS_EXPORT QString winErrorMessage(unsigned long error) +{ + QString rc = QString::fromLatin1("#%1: ").arg(error); + ushort *lpMsgBuf; + + const int len = FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL); + if (len) { + rc = QString::fromUtf16(lpMsgBuf, len); + LocalFree(lpMsgBuf); + } else { + rc += QString::fromLatin1("<unknown error>"); + } + return rc; +} + +} // namespace Utils +} // namespace Core |