Klabautermann hat folgendes geschrieben: |
|
Das ist wieder einmal eine typische Erleichterung von Delphi.
So sieht das etwa mit API-Funktionen aus.
Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
| procedure CopyToClipboard(s : String); var hMem : cardinal; sCopyData : string; pMem : PChar; begin if not OpenClipboard(0) then exit; try if not EmptyClipboard then exit; sCopyData := s; // s = Memo1.Text; hMem := GlobalAlloc(GMEM_MOVEABLE,Length(sCopyData) + 1); if hMem = 0 then exit; pMem := GlobalLock(hMem); try CopyMemory(pMem,PChar(sCopyData),Length(sCopyData) + 1); finally GlobalUnlock(hMem); end; SetClipboardData(CF_TEXT,hMem); finally CloseClipboard; end; end; |