10-08-2009, 12:32 PM
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;
}