EnumWindows这样用也错了?(50分)

  • 主题发起人 主题发起人 nwskyblue
  • 开始时间 开始时间
N

nwskyblue

Unregistered / Unconfirmed
GUEST, unregistred user!
//只检索第一个top_level窗口的句柄,测试EnumWindows的用法<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; xx : Integer;<br>begin<br>&nbsp; xx :=0;<br>&nbsp;if enumwindows(@EnumWindowsProc,xx) then<br>&nbsp; &nbsp;showmessage('success');<br>end;<br><br>//EnumWindowProc已经声明为stdcall<br>function TForm1.EnumWindowsProc(hwnd: cardinal; lParam: integer): Boolean;<br>begin<br>&nbsp; showmessage(inttostr(hwnd));<br>&nbsp; result := false;<br>end;<br><br>居然提示"Variable required",我对照函数类型,没错啊,郁闷.........
 
var<br>&nbsp; Form1: TForm1; &nbsp;<br>&nbsp; //不要放在TForm1中<br>&nbsp; function EnumWindowsProc(hwnd: THandle; lParam: Cardinal): Boolean;stdcall;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; xx : Integer;<br>begin<br>&nbsp; xx :=0;<br>&nbsp;if enumwindows(@EnumWindowsProc,xx) then<br>&nbsp; &nbsp;showmessage('success');<br>end;<br><br>//EnumWindowProc已经声明为stdcall,不要声明在TForm1中<br>function EnumWindowsProc(hwnd: THandle; lParam: Cardinal): Boolean;<br>begin<br>&nbsp; showmessage(inttostr(hwnd));<br>&nbsp; result := false;<br>end;<br>
 
接受答案了.
 
后退
顶部