How to get running process in Lazarus

2.4k views Asked by At

I use Lazarus IDE and my question is:

How to get running process in Lazarus? (only in Lazarus)

this work is easy in delphi by http://forum.codecall.net/topic/72604-getting-running-processes-list/

1

There are 1 answers

0
Gergely Tóth On

I think the unit tlhep32 should be replaced with JwaTlHelp32.

This simple one button, one memo app works in laz v1.6:

uses ...windows, jwatlhelp32;

var ...Snapshot: THandle; pe: TProcessEntry32;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
  try
    pe.dwSize := SizeOf(pe);
    if Process32First(Snapshot, pe) then
      while Process32Next(Snapshot, pe) do  memo1.Lines.Add(pe.szExeFile);
  finally
    CloseHandle(Snapshot);
  end;
end;