diff --git a/src/tools/qtcdebugger/main.cpp b/src/tools/qtcdebugger/main.cpp index 2f1e648647a..80c39de8edf 100644 --- a/src/tools/qtcdebugger/main.cpp +++ b/src/tools/qtcdebugger/main.cpp @@ -51,6 +51,7 @@ enum { debug = 0 }; static const char *titleC = "Qt Creator Debugger"; static const char *organizationC = "Nokia"; +static const char *applicationFileC = "qtcdebugger"; static const WCHAR *debuggerRegistryKeyC = L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"; // Optional @@ -67,7 +68,7 @@ static inline QString wCharToQString(const WCHAR *w) { return QString::fromUtf16 #endif -enum Mode { HelpMode, PromptMode, ForceCreatorMode, ForceDefaultMode }; +enum Mode { HelpMode, InstallMode, UninstallMode, PromptMode, ForceCreatorMode, ForceDefaultMode }; Mode optMode = PromptMode; bool optIsWow = false; @@ -112,6 +113,10 @@ static bool parseArguments(const QStringList &args, QString *errorMessage) optMode = ForceCreatorMode; } else if (arg == QLatin1String("default")) { optMode = ForceDefaultMode; + } else if (arg == QLatin1String("install")) { + optMode = InstallMode; + } else if (arg == QLatin1String("uninstall")) { + optMode = UninstallMode; } else if (arg == QLatin1String("wow")) { optIsWow = true; } else { @@ -134,9 +139,16 @@ static bool parseArguments(const QStringList &args, QString *errorMessage) } } } - if (optMode != HelpMode && argProcessId == 0) { - *errorMessage = QString::fromLatin1("Please specify the process-id."); - return false; + switch (optMode) { + case HelpMode: + case InstallMode: + case UninstallMode: + break; + default: + if (argProcessId == 0) { + *errorMessage = QString::fromLatin1("Please specify the process-id."); + return false; + } } return true; } @@ -154,10 +166,12 @@ static void usage(const QString &binary, const QString &message = QString()) str << "" << message << ""; } str << "
"
- << "Usage: " << QFileInfo(binary).baseName() << "[-wow] [-help|-?|qtcreator|default] <process-id> <event-id>\n"
+ << "Usage: " << QFileInfo(binary).baseName() << "[-wow] [-help|-?|qtcreator|default|install|uninstall] <process-id> <event-id>\n"
<< "Options: -help, -? Display this help\n"
<< " -qtcreator Launch Qt Creator without prompting\n"
<< " -default Launch Default handler without prompting\n"
+ << " -install Install itself (requires administrative privileges)\n"
+ << " -uninstall Uninstall itself (requires administrative privileges)\n"
<< " -wow Indicates Wow32 call\n"
<< ""
<< "To install, modify the registry key HKEY_LOCAL_MACHINE\\" << wCharToQString(debuggerRegistryKeyC) @@ -169,6 +183,8 @@ static void usage(const QString &binary, const QString &message = QString()) << "" << "
On 64-bit systems, do the same for the key HKEY_LOCAL_MACHINE\\" << wCharToQString(debuggerWow32RegistryKeyC) << ", " << "setting the new value to
\"" << QDir::toNativeSeparators(binary) << "\" -wow %ld %ld" + << "
How to run a command with administrative privileges:
" + << "runas /env /noprofile /user:Administrator \"command arguments\"" << "