Platform SDK: Interprocess Communications

Memory and the Clipboard

A memory object that is to be placed on the clipboard should be allocated by using the GlobalAlloc function with the GMEM_MOVEABLE flag.

After a memory object is placed on the clipboard, ownership of that memory handle is transferred to the system. When the clipboard is emptied and the memory object has one of the following clipboard formats, the system frees the memory object by calling the indicated Win32 function:

Function to free object Clipboard format
DeleteMetaFile CF_DSPENHMETAFILE
CF_DSPMETAFILEPICT
CF_ENHMETAFILE
CF_METAFILEPICT
DeleteObject CF_BITMAP
CF_DSPBITMAP
CF_PALETTE
GlobalFree CF_DIB
CF_DIBV5
CF_DSPTEXT
CF_OEMTEXT
CF_TEXT
CF_UNICODETEXT
None CF_OWNERDISPLAY

When the clipboard is emptied of a CF_OWNERDISPLAY object, the application itself must free the memory object.