Step by Step

雪压枝头低,虽低不着泥。一朝红日出,依旧与天齐。

获取打开的记事本内容(转自万一博客)

procedure TForm1.btn1Click(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 2021-05-30 22:33  生活照旧  阅读(87)  评论(0编辑  收藏  举报

导航