如何枚举系统中所有窗口?(50分)

  • 主题发起人 主题发起人 heman888
  • 开始时间 开始时间
H

heman888

Unregistered / Unconfirmed
GUEST, unregistred user!
请问各位大虾:如何枚举系统中所有窗口?
 
unit Unit4;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp;EnumWindowsProc=function(hwnd:Thandle; lP:LPARAM):boolean;stdcall;<br><br>type<br>&nbsp; TForm4 = class(TForm)<br>&nbsp; &nbsp; ListBox1: TListBox;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; &nbsp; procedure ListBox1DblClick(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>&nbsp; function EnumWin(hwnd:Thandle; lP:LPARAM):boolean;stdcall;<br><br>var<br>&nbsp; Form4: TForm4;<br><br>implementation<br><br>{$R *.DFM}<br><br>function EnumWin(hwnd:Thandle; lP:LPARAM):boolean;stdcall;<br>var<br>&nbsp; buffer:array[0..255] of Char;<br>&nbsp; list:TListBox;<br>begin<br>&nbsp; List:=TListBox(lp);<br>&nbsp; GetwindowText(hwnd,buffer,256);<br>&nbsp; if StrLen(buffer)&gt;0 then<br>&nbsp; begin<br>&nbsp; &nbsp; list.Items.AddObject(buffer,Tobject(hwnd));<br>&nbsp; end;<br>end;<br><br>procedure TForm4.Button1Click(Sender: TObject);<br>var<br>&nbsp; pp:EnumWindowsProc;<br>begin<br>&nbsp; pp:=MakeProcInstance(@ENumWin,HInstance);<br>&nbsp; EnumWindows(@pp,lparam(Listbox1));<br>&nbsp; FreeProcInstance(@pp);<br>end;<br><br>end.<br>你看这段行不行,从前贴子里的
 
&gt;&gt;你看这段行不行,从前贴子里的<br>不行
 
后退
顶部