枚举窗口

soloplayer 2003-01-31 12:34:19
怎样用api来枚举当前运行的所有程序?
...全文
65 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
snake_eye 2003-02-02
  • 打赏
  • 举报
回复
enumwindowchild,
回掉函数可以一一列举所有窗口!
Billy_Chen28 2003-01-31
  • 打赏
  • 举报
回复
新年快乐!羊年发洋财!

再来一个简单点的:
procedure TForm1.Button1Click(Sender: TObject);
var
lppe: TProcessEntry32;
found : boolean;
Hand : THandle;
begin
Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(Hand,lppe);
while found do begin
ListBox1.Items.Add(StrPas(lppe.szExeFile));
found := Process32Next(Hand,lppe);
end;
end;
Billy_Chen28 2003-01-31
  • 打赏
  • 举报
回复
新年快乐!羊年发洋财!

uses tlhelp32;
Function ListRuningExeName(ExeName:TStrings):Integer;
Var
iHandle:LongInt;
lppe:tagProcessentry32;
i:integer;
begin
i:=0;
iHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
try
if iHandle=-1 then Raise Exception.Create('调用失败!');
Process32First(iHandle,lppe);
While GetLastError<>ERROR_NO_MORE_FILES do
begin
inc(i);
ExeName.Add(lppe.szExeFile);
Process32Next(iHandle,lppe);
end;
except
On E:Exception do begin
Application.HandleException(E);
i:=-1;
end;

end;
finally
CloseHandle(iHandle);
Result:=i;
end;
end;
纯冰糖 2003-01-31
  • 打赏
  • 举报
回复
nit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
TForm1 = class(TForm)
ListBox1: TListBox;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var hcurrentwindow:hwnd;
sztext:array[0..254]of char;
begin
hcurrentwindow:=getwindow(handle,gw_hwndfirst);
while hcurrentwindow <> 0 do
begin
if getwindowtext(hcurrentwindow,@sztext,255) > 0 then
listbox1.Items.Add(strpas(@sztext));
hcurrentwindow:=getwindow(hcurrentwindow,gw_hwndnext);
end;
end;

end.
grail_ 2003-01-31
  • 打赏
  • 举报
回复

够快的
看来cg1120的代码库很酷呀!
很佩服:)
羊年快乐

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧