如何获得当前系统正在运行的所有程序的名字和CLASS
【打印文章】
procedure TForm_main.Button1Click(Sender: TObject);
var
t:array [0..254] of char;
Name:PChar; // 名字
i,j,L,hnow:integer; //// 名字的长度
pos:tpoint;
begin
setlength(intlist,254);
i:=0;
j:=0;
memo1.Lines.clear;
Memo1.Lines.Add('序号'+chr(9)+'句柄'+chr(9)+'程序');
while i<=65536 do
begin
//if i=3000 then abort ;
edit1.text:=inttostr(i);
self.Repaint;
L:=GetWindowTextLength(i)+1; // 得到名字长度,并将长度加1
GetMem(Name,L); //为将要得到的名字分配内存
GetWindowText(i,Name,L); //得到名字
FreeMem(Name,0); // 释放分配的内存
if GetWindowText(i, @name, 255)>0 then
begin
intlist[j]:=i;
inc(j);
Memo1.Lines.Add(inttostr(Memo1.Lines.Count)+chr(9)+inttostr(i)+chr(9)+trim(strpas(@name)));
end;
GetCursorPos(pos);
hNow:=WindowFromPoint(Pos);
GetClassName(hNow,@t,255);
if string(t)='Edit' then
Memo1.Lines.Add('Edit: '+inttostr(Memo1.Lines.Count)+chr(9)+inttostr(i)+chr(9)+trim(strpas(@name)));;
inc(i);
end;
end;
//以上控件名,都是标准命名的控件名,请自己定义一下即可。
var
t:array [0..254] of char;
Name:PChar; // 名字
i,j,L,hnow:integer; //// 名字的长度
pos:tpoint;
begin
setlength(intlist,254);
i:=0;
j:=0;
memo1.Lines.clear;
Memo1.Lines.Add('序号'+chr(9)+'句柄'+chr(9)+'程序');
while i<=65536 do
begin
//if i=3000 then abort ;
edit1.text:=inttostr(i);
self.Repaint;
L:=GetWindowTextLength(i)+1; // 得到名字长度,并将长度加1
GetMem(Name,L); //为将要得到的名字分配内存
GetWindowText(i,Name,L); //得到名字
FreeMem(Name,0); // 释放分配的内存
if GetWindowText(i, @name, 255)>0 then
begin
intlist[j]:=i;
inc(j);
Memo1.Lines.Add(inttostr(Memo1.Lines.Count)+chr(9)+inttostr(i)+chr(9)+trim(strpas(@name)));
end;
GetCursorPos(pos);
hNow:=WindowFromPoint(Pos);
GetClassName(hNow,@t,255);
if string(t)='Edit' then
Memo1.Lines.Add('Edit: '+inttostr(Memo1.Lines.Count)+chr(9)+inttostr(i)+chr(9)+trim(strpas(@name)));;
inc(i);
end;
end;
//以上控件名,都是标准命名的控件名,请自己定义一下即可。
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】
