试试下面的代码,应该实现你的要求了:<br>procedure TForm2.Button1Click(Sender: TObject);<br>const<br> NotepadCaption = 'Untitled - Notepad';<br><br> function FindTargetHWnd: THandle;<br> var<br> HPwnd: THandle;<br> begin<br> HPwnd := FindWindow(nil, PChar(NotepadCaption));<br> Result := FindWindowEx(HPwnd, 0, 'Edit', nil);<br> end;<br>var<br> S: string;<br> Hwnd: THandle;<br>begin<br> S := Memo1.Text;<br> Hwnd := FindTargetHWnd;<br> SendMessage(Hwnd, WM_SETTEXT, 0, Integer(S));<br> SendMessage(Hwnd, EM_SETSEL, 0, -1);<br>end;<br>