Using API

delphi package - easy access to kernel objects etc.
Post Reply
seth
Posts: 3
Joined: Tue Jul 05, 2005 2:35 pm

Using API

Post by seth »

Hello there!!
I saw your solution about the process list:
uses madKernel;

var i1 : integer;
s1 : string;
begin
with Processes do
for i1 := 0 to ItemCount - 1 do
s1 := s1 + #13#10 + Items[i1].ExeFile;
MessageBox(0, pchar(s1), 'running processes', 0);
How is it possible to get the process list using windows API??
:confused:
uall
Posts: 254
Joined: Sun Feb 20, 2005 1:24 pm

Post by uall »

Code: Select all


uses tlhelp32;

function FindAllProcesses: string;
var
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
  ContinueLoop: BOOL;
  s: string;
begin
  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle,FProcessEntry32);
  s := '';
  while ContinueLoop do
  begin
    s := s+uppercase(extractfilename(FProcessEntry32.szExeFile))+#13#10;
    ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
  end;
  if length(s) > 0 then result := copy(s,1,length(s)-2);
  CloseHandle(FSnapshotHandle);
end;
Post Reply