Re: Need list of running Apps
- From: erewhon@xxxxxxxxxx (J French)
- Date: Mon, 21 Aug 2006 13:36:19 GMT
On Mon, 21 Aug 2006 10:19:46 +0100, "Roy Coates"
<roy@xxxxxxxxxxxxxxxxx> wrote:
Hi, it's been quite a while since I've used Delphi - and I'm stuck.
I need to build a list of running user apps, specifically the applications title. eg:- "Notepad - myfile.txt"
Can anyone help? Google hasn't !
I don't think this is mine, it does not look like it
- it is Ok for 95, 98, 2K and XP - problems with pure NT
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Uses TlHelp32;
procedure TForm1.Button1Click(Sender: TObject);
var
handler: THandle;
data: TProcessEntry32;
nm : pchar;
phndl,hndl : LongInt;
begin
handler := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
data.dwSize := Sizeof(TProcessEntry32);
// First item
if Process32First(handler, data) then
begin
nm := data.szExeFile;
while Process32Next(handler, data) do begin
nm := data.szExeFile;
hndl := data.th32ProcessID;
phndl := data.th32ParentProcessID;
listbox1.Items.Add(strpas(nm)+' '+ IntToStr(hndl)+' '+
IntToStr(phndl));
end;
end;
CloseHandle( Handler );
// Add our PID
GetWindowThreadProcessID( Self.Handle, Addr(phndl) );
listbox1.Items.Add( IntToStr(phndl) );
Listbox1.Perform( LB_SETHORIZONTALEXTENT, Listbox1.Width *2, 0 );
End;
end.
.
- References:
- Need list of running Apps
- From: Roy Coates
- Need list of running Apps
- Prev by Date: Re: Delphi threading
- Next by Date: Re: Need list of running Apps
- Previous by thread: Need list of running Apps
- Next by thread: Re: Need list of running Apps
- Index(es):