System Delphi

Title: How to list all running processes
Question: This is a small program that lists all running processes along with some basic info for each and the ability to terminate any of them. It uses a few Windows API calls. Executable is compressed with UPX .94. Use at your own risk ...
Answer:
The main functions to get the list of processes is
-Process32First and
-Process32Next
It retrieves information about the first and next process encountered in a system snapshot.
CreateToolHelp32SnapShot must be called before. It takes a snapshot of the processes and the heaps, modules, and threads used by the processes.
Finally the code looks somehow like this:
var
Proc : TProcessEntry32;
Snap : THandle;
...
Snap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS,0);
Proc.dwSize := SizeOf(TProcessEntry32);
Process32First(Snap,Proc);
repeat
// add into list...
until (not Process32Next(Snap,Proc));
TerminateProces is used to kill a task.
Download program plus source GETPROCS.ZIP
(c) by
Ardian Dhrimaj
bisha@angelfire.com