Wednesday, September 05, 2012

Get Clipboard Size : Windows

The windows clipboard has a group of parallel versions of the same data.

To get clipboard data you use the function GetClipboardData with the format-ID parameter.
This gives you the handle to the Global Memory block that contains this particular version of the clipboard data.
In-order to get the size of this block in bytes use: GlobalSize on the handle got by GetClipboardData.

HGLOBAL hMem;
hMem = GetClipboardData(uformat_id);
cbSize = GlobalSize(hMem); // got the size in cbSize
pData = GlobalLock(hMem);

No comments: