Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List Processes
#1
Just a small c++ script I found ages ago but editted slightly by me, when run this program will show all process's that are running as well as their ids. Can be usefull for use with other scripts or to help protect your system from viruses


Code:
/*When run this program will show all processes that are running as well as their ids*/
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>

int main(void)
{
    int info;
    HANDLE Snap;
    PROCESSENTRY32 proc32;
    
    Snap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);/*take a snap of all processes*/
  if(Snap==INVALID_HANDLE_VALUE)
  {
    printf("Error creating snapshot of current processes");
    return EXIT_FAILURE;
  }
  proc32.dwSize=sizeof(PROCESSENTRY32); /*set size of structure*/  
  
  system("cls");
  printf("Process Viewer\n");
  printf("PID:\t\tPROCESS NAME:\n");
  while((Process32Next(Snap,&proc32))==TRUE)/*while we haven't reached the final process*/
  {
      printf("\n%d\t\t%s",proc32.th32ProcessID,proc32.szExeFile);/*print pid and processname*/
  }
  printf("\n");
  CloseHandle(Snap);/*cleaning up*/  
  system("PAUSE");            
  return EXIT_SUCCESS;
}
Reply


Messages In This Thread
List Processes - by brett7 - 10-08-2009, 12:32 PM
RE: List Processes - by charnet3d - 10-09-2009, 02:44 PM
RE: List Processes - by brett7 - 10-09-2009, 03:29 PM
RE: List Processes - by Akshay* - 10-10-2009, 05:44 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)