QProcess方法
1.判断进程是否存在
bool checkProcessByQProcess(const QString &strExe)
{
bool bResult = false;
// 判断进程是否存在
QProcess tasklist;
tasklist.start("tasklist",
QStringList() << "/NH"
<< "/FO" << "CSV"
<< "/FI" << QString("IMAGENAME eq %1").arg(strExe));
tasklist.waitForFinished();
QString strOutput = tasklist.readAllStandardOutput();
//如果进程存在,则结束进程
if (strOutput.startsWith(QString("\"%1").arg(strExe)))
{
qInfo() << "check process";
bResult = true;
}
return bResult;
}
bool checkProc