#include <iostream>
#include <windows.h>
#include <Tlhelp32.h>
using namespace std;
int main()
{
bool List = FALSE;
unsigned short int PID;
while(1)
{
while(List == FALSE)
{
PROCESSENTRY32 pe32;
HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
pe32.dwSize = sizeof(PROCESSENTRY32);
Process32First(hProcessSnap,&pe32);
cout << "Name:" << pe32.szExeFile << "\tPID:" << pe32.th32ProcessID;
while(Process32Next(hProcessSnap,&pe32))
cout << "\nName:" << pe32.szExeFile << "\tPID:" << pe32.th32ProcessID;
CloseHandle(hProcessSnap);
List = TRUE;
}
while(List == TRUE)
{
cout << "\nType in PID to kill a process\n";
cin >> PID;
HANDLE hproc = OpenProcess(PROCESS_ALL_ACCESS,0,PID);
if((TerminateProcess(hproc,0)) != 0)
cout << "Process Killed\n";
List = FALSE;
}
}
return 0;
}