1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 // Some functions used by qtcreator.exe and qtcdebugger.exe to check if
35 // qtcdebugger is currently registered for post-mortem debugging.
36 // This is only needed on Windows.
38 #ifndef REGISTRYACCESS_H
39 #define REGISTRYACCESS_H
41 #include <QtCore/QString>
42 #include <QtCore/QLatin1String>
46 namespace RegistryAccess {
48 static const char *debuggerApplicationFileC = "qtcdebugger";
49 static const WCHAR *debuggerRegistryKeyC = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug";
50 static const WCHAR *debuggerRegistryValueNameC = L"Debugger";
52 static inline QString wCharToQString(const WCHAR *w)
54 return QString::fromUtf16(reinterpret_cast<const ushort *>(w));
57 QString msgFunctionFailed(const char *f, unsigned long error);
59 static inline QString msgRegistryOperationFailed(const char *op, const WCHAR *valueName, const QString &why)
61 QString rc = QLatin1String("Registry ");
62 rc += QLatin1String(op);
63 rc += QLatin1String(" of ");
64 rc += wCharToQString(valueName);
65 rc += QLatin1String(" failed: ");
70 bool registryReadStringKey(HKEY handle, // HKEY_LOCAL_MACHINE, etc.
71 const WCHAR *valueName,
73 QString *errorMessage);
75 bool openRegistryKey(HKEY category, // HKEY_LOCAL_MACHINE, etc.
79 QString *errorMessage);
81 QString debuggerCall(const QString &additionalOption = QString());
83 bool isRegistered(HKEY handle, const QString &call, QString *errorMessage, QString *oldDebugger = 0);
85 } // namespace RegistryAccess
87 #endif // REGISTRYACCESS_H