K
koy0755
Unregistered / Unconfirmed
GUEST, unregistred user!
得到所以窗口的标题。以下代码能正常运行个字符。第二个程序加入了strlcopy想得到标题的前8个字符,就运行不了了。<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> ListBox1: TListBox;<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br>function enumwindowsproc(ahwnd:hwnd;alparam:lparam):boolean;stdcall;<br>var wintext,w2char;<br>begin<br> result:=true;<br> getwindowtext(ahwnd,wintext,100);<br> w2:=wintext;<br> form1.ListBox1.Items.add(inttostr(ahwnd)+'='+w2);<br><br> end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>whwnd:hwnd;<br>smeschar;<br>begin<br>enumwindows(@enumwindowsproc,0);<br><br>end;<br><br>end.<br>