//该函数是回调函数的入口地址,有用声明,直接写在implementation下
function 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;
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]));
Edit1.text:= StrPas(buffer);
end;
end;