Code:
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
ListBox2.Clear;
while Integer(ContinueLoop) <> 0 do
begin
ListBox.Items.Add(FProcessEntry32.szExeFile); //ListBox /MEMO ...
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
ListBox.Sorted := True; //Serves to sort the list of processes alphabetically
end;
putting in a MaskEdit
Code:
begin
MaskEdit.Text := listbox.Items.Strings[ListBox.itemIndex];
end;