1 QString strProcessName = "QQ.exe";
2 bool bIsExist = false; // 进程是否存在
3 QProcess process;
4 process.start("tasklist.exe");
5 if (process.waitForFinished())
6 {
7 QByteArray result = process.readAll();
8 QString exe = QString(result);
9 if (exe.contains(strProcessName))
10 {
11 bIsExist = true; // 找到了
12 }
13 }
14 process.close();
15
16 //结束进程
17 QStringList list;
18 list << "/im" << strProcessName << "/f";
19 QProcess::execute(QLatin1String("taskkill"), list); //程序需以管理员权限运行