GetAsHandle (Delphi)
Description
The following code locks the memory corresponding to the text on the Clipboard, then reads the text.
Code
uses clipbrd;
procedure TForm1.Button1Click(Sender: TObject);
var
MyHandle: THandle;
TextPtr: PChar;
begin
ClipBoard.Open;
try
{$IFNDEF UNICODE}
MyHandle := Clipboard.GetAsHandle(CF_TEXT);
{$ELSE}
MyHandle := Clipboard.GetAsHandle(CF_UNICODETEXT);
{$ENDIF}
TextPtr := GlobalLock(MyHandle);
ListBox1.Items.Add(StrPas(TextPtr));
GlobalUnlock(MyHandle);
finally
Clipboard.Close;
end;
end;
Uses
- Vcl.Clipbrd.TClipboard.GetAsHandle ( fr | de | ja )
- Vcl.Clipbrd.TClipboard.Open ( fr | de | ja )
- Vcl.Clipbrd.TClipboard.Close ( fr | de | ja )
- System.SysUtils.StrPas ( fr | de | ja )