uses
tlhelp32;
type
 TForm1 = class(TForm)
 Button1: TButton;
 lvView: TListView;
 procedure Button1Click(Sender: TObject);
 private
 { Private declarations }
 procedure ViewProccess;
 public
 { Public declarations }
 end;
var
 Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ViewProccess;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;//used to store proccess information that are currnently running
sFileName:string;
ls:TlistItem;
begin
 lvView.Clear;
 //Takes a snapshot of the processes and the heaps, modules, and threads used by the processes
 FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
 //Retrieves information about the first process encountered in a system snapshot
 ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
 while integer(ContinueLoop) <> 0 do //stops until there is no more processes to check
 begin
 sFileName:= UpperCase(ExtractFileName(FProcessEntry32.szExeFile));
 ls:=TlistItem.Create(lvView.items);
 ls.Caption:=sFileName;
 ls.SubItems.add(intTostr(FProcessEntry32.th32ProcessID));
 ls.SubItems.add(intTostr(FProcessEntry32.cntThreads));
 lvView.Items.Add;
 lvView.Items[(lvView.items.count-1)]:=ls;
 //gets the next process encountered in a system snapshot
 ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
 end;
CloseHandle(FSnapshotHandle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
 ViewProccess;
end;
This is the DFM text or code.
object Form1: TForm1
 Left = 391
 Top = 193
 Width = 317
 Height = 325
 Caption = 'My Proccess Viewer'
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = 'MS Sans Serif'
 Font.Style = []
 OldCreateOrder = False
 PixelsPerInch = 96
 TextHeight = 13
 object Button1: TButton
 Left = 112
 Top = 272
 Width = 75
 Height = 25
 Caption = 'View'
 TabOrder = 0
 OnClick = Button1Click
 end
 object lvView: TListView
 Left = 32
 Top = 8
 Width = 250
 Height = 257
 Columns = <
 item
 Caption = 'FileName'
 Width = 100
 end
 item
 Caption = 'ProcessID'
 Width = 70
 end
 item
 Caption = 'Threads'
 Width = 60
 end>
 TabOrder = 1
 ViewStyle = vsReport
 end
end