Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board For the Consise Programming Contest Download Source Code
Author Details Code Information
STN

Pinned 1 Codes
Posted 0 Coding Articles

Send A Message
View Coders Profile
Language C++
Expires Never
Length 887 Characters (34 Lines)
Password no password
Description

I wrote this program for the Consise Programming Contest by Cinjection. 34 lines of code with complete indentation. Lists processes and can kill processes through PID(Process Id).
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <Tlhelp32.h>
  4. using namespace std;
  5. int main()
  6. {
  7.           bool List = FALSE;
  8.           unsigned short int PID;
  9.           while(1)
  10.           {
  11.                     while(List == FALSE)
  12.                     {
  13.                               PROCESSENTRY32 pe32;
  14.                               HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  15.                               pe32.dwSize = sizeof(PROCESSENTRY32);
  16.                               Process32First(hProcessSnap,&pe32);
  17.                               cout << "Name:" << pe32.szExeFile << "\tPID:" << pe32.th32ProcessID;
  18.                               while(Process32Next(hProcessSnap,&pe32))
  19.                                         cout << "\nName:" << pe32.szExeFile << "\tPID:" << pe32.th32ProcessID;
  20.                               CloseHandle(hProcessSnap);
  21.                               List = TRUE;
  22.                     }
  23.                     while(List == TRUE)
  24.                     {
  25.                               cout << "\nType in PID to kill a process\n";
  26.                               cin >> PID;
  27.                               HANDLE hproc = OpenProcess(PROCESS_ALL_ACCESS,0,PID);
  28.                               if((TerminateProcess(hproc,0)) != 0)
  29.                                         cout << "Process Killed\n";
  30.                               List = FALSE;
  31.                     }
  32.           }
  33.           return 0;
  34. }
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
Page 1 of 1
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved