Function EnumWndProc(wnd:HWND;lParam:LPARAM):bool;stdcall;<br>我已在接口部分申明;可以编译。<br>将LstWnd.Items.Add(InttoStr(wnd));改为Form1.LstWnd.Items.Add(InttoStr(wnd));后<br>错误消除,可是wnd一直为调用EnumWindows时所给的lParam的值呀.<br>这是为什么啊?请各位高手不帮帮忙!先谢过!<br>单元文件如下:<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> LstWnd: TListBox;<br> btnRefresh: TButton;<br> btnClose: TButton;<br> procedure btnCloseClick(Sender: TObject);<br> procedure btnRefreshClick(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> function enumwndProc(wnd:HWND;lParam:LPARAM):bool;stdcall;<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.btnCloseClick(Sender: TObject);<br>begin<br> Close;<br>end;<br><br>procedure TForm1.btnRefreshClick(Sender: TObject);<br>begin<br> Form1.LstWnd.Clear;<br> EnumWindows(@TForm1.enumwndProc,LPARAM(1));//application.handle));<br>end;<br><br>function TForm1.enumwndProc(wnd: HWND; lParam: LPARAM): bool;stdcall;<br>begin<br> Form1.LstWnd.Items.Add(IntToStr(wnd));<br> if wnd=0 then<br> Result:=false<br> else<br> Result:=true;<br>end;<br><br>end.