6 #include <QStringBuilder>
25 PROCESS_INFORMATION processInfo;
26 memset(&processInfo, 0,
sizeof(processInfo));
28 STARTUPINFO startupInfo;
29 memset(&startupInfo, 0,
sizeof(startupInfo));
30 startupInfo.cb =
sizeof(startupInfo);
33 if (!arguments.
isEmpty()) { command +=
" \"" % arguments.
join(
"\" \"").
replace(
'/',
'\\') %
'"'; }
36 flags |= NORMAL_PRIORITY_CLASS;
37 flags |= CREATE_UNICODE_ENVIRONMENT;
38 flags |= CREATE_NEW_CONSOLE;
40 Q_ASSERT(command.
length() <= MAX_PATH);
41 std::array<WCHAR, MAX_PATH> wszCommandLine = { {} };
44 int result = CreateProcess(
nullptr, wszCommandLine.data(),
nullptr,
nullptr, inherit, flags,
nullptr,
nullptr,
45 &startupInfo, &processInfo);
49 CLogMessage(
static_cast<CProcessCtrl *
>(
nullptr)).warning(u
"Failed to start %1: %2")
50 << program << GetLastError();
54 CloseHandle(processInfo.hProcess);
55 CloseHandle(processInfo.hThread);
CProcessCtrl(QObject *parent=nullptr)
Constructor.
static bool startDetached(const QString &program, const QStringList &arguments, bool withConsoleWindow)
Start a programm detached and without any console window.
Free functions in swift::misc.
bool startDetachedWithConsoleWindow(const QString &program, const QStringList &arguments)
bool isEmpty() const const
QStringList arguments() const const
QString program() const const
bool startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
qsizetype length() const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
qsizetype toWCharArray(wchar_t *array) const const
QString join(QChar separator) const const
unsigned long DWORD
Fake Windows DWORD.