问题来源: http://www.cnblogs.com/del/archive/2008/11/15/1334237.html#1784570
procedure TForm1.Button1Click(Sender: TObject); var h: HWND; p: Pointer; Len: Integer; begin h := FindWindow('Notepad', nil); if h = 0 then Exit; h := GetWindow(h, GW_CHILD); if h = 0 then Exit; Len := SendMessage(h, WM_GETTEXTLENGTH, 0, 0) + 1; p := GlobalAllocPtr(0, Len * SizeOf(Char)); SendMessage(h, WM_GETTEXT, Len, Cardinal(p)); ShowMessage(PChar(p)); GlobalFreePtr(p); end;