QT 强制杀死进程

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

posted @ 2016-06-10 21:35  findumars  Views(4796)  Comments(0Edit  收藏  举报