如何枚举当前运行的所有进程?在win9x下、winnt下、win2000、winxp都能运行?分不够还可以再加!!!!
解决方案 »
- 如何获得ActiveForm所在网页中的IP地址?兄弟请进。
- myling(阿德) 关于《NeHe的opengl框架delphi版》
- 怎么定义一个工程级的变量呀?
- 有谁能教我写这个类啊
- 这个软件每次输入一个员工的时候需要打开的grid都是空白的
- DBGridEh显示时某些字段为varbytes ,该如何解决
- 三层结构MIDAS搞不定了.
- 用OLe和formula one6控件 打印(制作)excel报表各有什么优缺点?
- DELPHI中SQL SQEVER的一個小問題
- BDE 最小安裝
- 主表append后但还没被写入数据时从表append好象写不进数据,是吗?
- 用InstallShield打包程序的问题,up有分
begin
memo1.Lines.Clear;
hand:=createtoolhelp32snapshot(th32cs_snapall,0);
found:=process32first(hand,lppe);
while found do
begin
//showmessage('123');
memo1.Lines.Add(strpas(lppe.szExeFile));
found:=process32next(hand,lppe);
end;
end;
procedure RunningAppList;
var
WinText:array [0..255] of char;
Handler:array [0..200] of LongInt;
RenHWND:integer;
Count:integer;
RetValue:LongInt;
WinTextLength:LongInt;
begin
Count:=0;
RenHWND:=GetWindow(Form1.Handle,GW_HWNDFIRST);
repeat
RetValue:=GetWindowText(RenHWND,@WinText,255);
if RetValue>0 then
begin
WinTextLength:=GetWindowTextLength(RenHWND);
Form1.ListView1.Items.Add;
Form1.ListView1.Items.Item[Count].Caption:=StrPas(@winText);
Form1.ListView1.Items.Item[count].SubItems.Add(IntToStr(RenHWND));
Form1.ListView1.Items.Item[count].SubItems.Add(inttostr(count));
Handler[Count]:=RenHWND;
Count:=count+1;
end;
RenHWND:=GetWindow(RenHWND,GW_HWNDNEXT);
until RenHWND=0;
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Tlhelp32;type
TForm1 = class(TForm)
Edit1: TEdit;
StaticText1: TStaticText;
Button1: TButton;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}
procedure Button1Click(Sender: TObject);
const
PROCESS_TERMINATE=$0001;
//进程的PROCESS_TERMINATE访问权限
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result:= 0;
FSnapshotHandle := CreateToolhelp32Snapshot
(TH32CS_SNAPPROCESS, 0);
//获取系统所有进程快照
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
//调用Process32First前用Sizeof(FProcessEntry32)填充FProcessEntry32.dwSize
ContinueLoop := Process32First(FSnapshotHandle,
FProcessEntry32);
//获取快照中第一个进程信息并保存到FProcessEntry32结构体中
while integer(ContinueLoop) <> 0 do
//循环枚举快照中所有进程信息
begin
form1.Memo1.Lines.Add(strpas(FProcessEntry32.szExeFile));
ContinueLoop := Process32Next(FSnapshotHandle,FProcessEntry32);
//查找下一个符合条件进程
end;
end;在WIN98、WIN2000下均可。