刚测试通过。原理是,记事本其实里面是由许多控件组成。所以找出记事本的句柄,得再找出控件的句柄。再用消息中的WM_GETTEXT.来得到文本。有问题再问。<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> hWindow, hControl: THandle;<br> sWindowText: PChar;<br>begin<br> hWindow := FindWindow(nil,'a.txt - 记事本');//记事本标题。<br> if hWindow = 0 then<br> begin<br> ShowMessage('未找到指定窗口');<br> Exit;<br> end;<br> hControl := FindWindowEx(hWindow, 0, 'EDIT', nil);<br> if hControl = 0 then<br> begin<br> ShowMessage('未找到指定控件');<br> Exit;<br> end;<br> GetMem(sWindowText, 100);<br> SendMessage(hControl, WM_GETTEXT, 100, LPARAM(sWindowText));<br> Memo1.Text:=sWindowText;<br> FreeMem(sWindowText);<br>end;