bool KillProcess(QString ProcessName)
{
bool result = false;
QString str1;
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0) ;
PROCESSENTRY32 pInfo;
pInfo.dwSize = sizeof(pInfo);
Process32First(hSnapShot, &pInfo);
do
{
str1 = (QString::fromUtf16(reinterpret_cast<const unsigned short *>(pInfo.szExeFile)));
if (str1 == ProcessName)
{
result = true;
QString cmd;
cmd = QString("taskkill /F /PID %1 /T").arg(pInfo.th32ProcessID);
system(cmd.toAscii());
}
} while(Process32Next(hSnapShot, &pInfo) );
return result;
}
http://blog.csdn.net/itjobtxq/article/details/8450449