终止可执行(exe)措施, 首先遍历历程, 找到历程名称对付的历程ID号, 然后按照历程ID, 终止历程.
示例代码: 包罗遍历历程代码, 和封锁代码.
代码:
/*
* main.cpp
*
* Created on: 2014.06.08
* Author: Spike
*//*vs 2012*/
#include <iostream>
#include <string>
#include <map>#include <windows.h>
#include <TlHelp32.h>using namespace std;
bool traverseProcesses (std::map<std::string, int>& _nameID)
{
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(pe32);HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE) {
std::cout << "CreateToolhelp32Snapshot Error!" << std::endl;;
return false;
}BOOL bResult =Process32First(hProcessSnap, &pe32);
int num(0);
while(bResult)
{
std::string name = pe32.szExeFile;
int id = pe32.th32ProcessID;//std::cout << "[" << ++num << "] : " <<"Process Name:"
//作者:csdn博客 Spike_King