GetAsHandle (C++)
Description
The following code locks the memory for text on the Clipboard, then reads the text.
Code
#include <Clipbrd.hpp>
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int TextHandle;
PChar pText;
Clipboard()->Open();
try
{
TextHandle = Clipboard()->GetAsHandle(CF_UNICODETEXT);
pText = (PChar)GlobalLock((HGLOBAL)TextHandle);
ListBox1->Items->Add(StrPas(pText));
GlobalUnlock((HGLOBAL)TextHandle);
}
catch (...)
{
Clipboard()->Close();
throw;
}
Clipboard()->Close();
}
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 )