Tasklist (Windows)

From LiteratePrograms
Jump to: navigation, search

This program is under development.
Please help to debug it. When debugging
is complete, remove the {{develop}} tag.


This code prints a list with all the tasks running in a Windows system. It can easily be expanded to display more information.

<<tasklist.c>>=

#include <windows.h>
#include <Tlhelp32.h>
#include <stdio.h>

//------------------------------------------------------------------------------------------------------------------
// printtasklist()
//
// prints a list over all tasks in the system
//------------------------------------------------------------------------------------------------------------------

void printtasklist(void)
{
  HANDLE          hSnapshot;
  BOOL            success;
  PROCESSENTRY32  lppe;

  hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);

  if(hSnapshot)
  {
    lppe.dwSize = (sizeof(PROCESSENTRY32));

    success = Process32First(hSnapshot,&lppe);
    if(success)
    {
      do
      {
        printf("%s\n",lppe.szExeFile);
      }
      while(Process32Next(hSnapshot,&lppe));
    }
    CloseHandle(hSnapshot);
  }
  return;
}

//------------------------------------------------------------------------------------------------------------------
// Entry point...
//------------------------------------------------------------------------------------------------------------------

int main(void)
{
  printtasklist();

  return 0;
}

Download code
hijacker
hijacker
hijacker
hijacker