I think some of the stuff at www.madshi.net might also be of some help. Jeremy
-----Original Message----- From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Conor Boyd Sent: 13 February 2009 08:20 To: NZ Borland Developers Group - Delphi List Subject: Re: [DUG] Getting command lines of all open programs John, Rather than enumerating windows, for this I think you'll want to enumerate processes instead. With a quick google for "enumerate windows processes" I found some leads you could pursue (including this one: http://www.codeproject.com/KB/threads/enumprocnt5.aspx) It's definitely relatively easy to get a list of running process ids (PIDs), and after that I presume there will be some function you can call to tell you all you need to know about a specific process. I presume what you want to do is possible since, for example, Sysinternals' Process Explorer displays the commandline for each process. Cheers, Conor -----Original Message----- From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of John Bird Is there a way to make a list of command lines of all open program windows? I have a utility that already captures the title bar of all open program windows - I use it when I suspend my laptop in case Windows won't resume (which it often doesn't) so I can know what windows were open. The next neat addition would be to have the command lines, so I can then have an option to reopen the programs that were open last time....now that would be neat eh? I remember seeing once a Delphi demo example of a task-manager like program which probably had stuff like this, but haven't been able to find it... FYI here is the essentials of how I find the open program windows, in case someone can see how to extend it a little....the ideal would be to make a second string list of the matching command lines. (It gets the titles of all open windows and writes them into a memo and a disk file). //http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_ 21550337.html procedure TfrmATMore.ATMakeWindowList; var TopWindow : HWND; WinName : array[0..Max_Path] of Char; x : Integer; function GetAllWindows(Handle: HWND; NotUsed: Pointer): Boolean; stdcall; var temp, pt : hwnd; begin Result := True; //Get parent of the window Temp:=Handle; repeat pt:=Temp; Temp:=GetParent( Temp ); until (Temp=0); if IsWindowVisible(pt) then begin //Just add without duplicates if frmATMore.WindowList1.IndexOf(Pointer(pt))=-1 then frmATMore.WindowList1.Add(Pointer(pt)); end; end; begin TopWindow := Handle; WindowList1 := TList.Create; Memo1.Lines.Clear; memo1.Lines.Add(xfAdate+spc+xfaTime+' Windows open are:'); try If NOT EnumWindows(@GetAllWindows,Longint(@TopWindow)) then RaiseLastOsError; for x := 0 to WindowList1.Count - 1 do begin GetWindowText(HWND(WindowList1[x]), WinName, SizeOf(WinName) - 1); if WinName<>'' then memo1.Lines.add(WinName); end; finally WindowList1.Free; end; memo1.Lines.add('______________________'); ...... memo1.lines.SaveToFile(ATSaveWindowsNamesFile); end; _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe