procedure TForm1.Button1Click(Sender: TObject); var hw, he: THandle; cName: array[0..32] of Char; sMsg: array[0..1024] of Char; begin hw := FindWindow(nil, PChar('未定标题 - 记事本')); if hw = 0 then Exit; he := FindWindowEx(hw, 0, nil, nil); while he <> 0 do begin GetClassName(he, cName, 32); if StrPas(cName) = 'Edit' then Break; {得到其句柄,此法笨} he := FindWindowEx(hw, he, nil, nil); end; SendMessage(he, WM_GETTEXT, 1024, Integer(@sMsg)); Memo1.Text := StrPas(sMsg); end;