I use the following code to step through all the top level processes running on the system..
Code: Select all
procedure BuildProcessList(tsl : TStringList);
var
i1 : integer;
pl : TDAProcess;
WinEXE : String;
WinHwnd : Cardinal;
ProcessHandle : IProcess;
begin
pl := EnumProcesses;
for i1 := 0 to high(pl) do
begin
try
WinEXE := ExtractFilename(pl[i1].exeFile);
WinHwnd := Process(pl[i1].exeFile).GetHandle(PROCESS_ALL_ACCESS).Handle;
ProcessHandle := MadKernel.Window(WinHwnd).OwnerProcess;
//CODE HERE TO TO DO STUFF
except
continue;
end;
end;
end;
I know I can use enumprocs to go through all the open windows, and then I am able to link the windows upto the EXE for my own tracking purposes, but I would like a way I could find or open a top level window, and be able to find all the sub windows that opened, and are owned by the main window.
Any suggestions would be great.
Regards,
Jeff Lawton