unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); var
  hwnd: Integer;
  buffer: array[0..255] of char;
begin
  hwnd := FindWindow('IEFrame',nil);
  if hwnd<> 0 then
  begin
   EnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@buffer[0]));   //这里出错了(第37行),Integer(@buffer[0])需要参数?
   memo1.Lines.Add(StrPas(buffer));
   GetWindowText(hwnd,buffer,255);
   memo1.Lines.Add(strpas(buffer));
  end;
end;
function TForm1.EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
var
  buffer: array[0..255] of char;
begin
  Result := True;
  GetClassName(hwnd,buffer,256);
  if StrPas(Buffer)='Edit' then
  begin
   SendMessage(hwnd,WM_GETTEXT,256,lparam);
   Result:=False;
  end;
end;
end.[Error] Unit1.pas(37): Variable required
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'

解决方案 »

  1.   

    function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall; 
    这个函数别定义为类的成员函数,定义为全局函数
      

  2.   

    这里出错了?
    function TForm1.EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall; 
    这样?
    function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall; 
      

  3.   

    @EnumChildWindowsProc改成@Tform1.EnumChildWindowsProc
      

  4.   

    function EnumChildWindowsProc(hwnd: THandle; lparam: LongInt): LongBool; stdcall;