uses strings, clipbrd;

var
  Buf: PChar;
  size: integer;

begin
  { How to write to the clipboard
  }
  openclipboard;
  Buf := StrNew('This is a little nice test.'#13#10'It should really work.'#13#10);
  SetClipboardData(cf_Text, Buf^, StrLen(Buf) + 1);
  { Buf doesn't belong to the application any more, don't free it. }
  closeclipboard;

  { Clear the Buf in order to prove that transfer really works...
  }
  StrCopy(Buf, 'Now it''s very empty');

  { How to read from the clipboard
  }
  openclipboard;
  size := getclipboarddatasize(cf_Text);
  GetMem(Buf, size);
  getclipboarddata(cf_Text, Buf^);
  writeln(buf);
  FreeMem(Buf, size);		{ Buf belongs to the application }
  closeclipboard;
end.
