获取打开的记事本内容(转自万一博客)
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;
宝剑锋从磨砺出,
梅花香自苦寒来。