随笔 - 2146  文章 - 97 评论 - 11767 trackbacks - 253

问题来源: 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;

posted on 2010-03-23 10:44  万一  阅读(...)  评论(...编辑  收藏