The GetClipboardData function retrieves data from the clipboard in a specified format. The clipboard must have been opened previously.
HANDLE GetClipboardData(
UINT uFormat |
// clipboard format |
); |
If the function succeeds, the return value is the handle of a clipboard object in the specified format.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
An application can enumerate the available formats in advance by using the EnumClipboardFormats function.
The clipboard controls the handle that the GetClipboardData function returns, not the application. The application should copy the data immediately. The application cannot rely on being able to make long-term use of the handle. The application must not free the handle nor leave it locked.
Clipboard Format |
Conversion Format |
Platform Support |
CF_BITMAP |
CF_DIB |
Windows NT, Windows 95 |
CF_DIB |
CF_BITMAP |
Windows NT, Windows 95 |
CF_DIB |
CF_PALETTE |
Windows NT, Windows 95 |
CF_ENHMETAFILE |
CF_METAFILEPICT |
Windows NT, Windows 95 |
CF_METAFILEPICT |
CF_ENHMETAFILE |
Windows NT, Windows 95 |
CF_OEMTEXT |
CF_TEXT |
Windows NT, Windows 95 |
CF_OEMTEXT |
CF_UNICODETEXT |
Windows NT |
CF_TEXT |
CF_OEMTEXT |
Windows NT, Windows 95 |
CF_TEXT |
CF_UNICODETEXT |
Windows NT |
CF_UNICODETEXT |
CF_OEMTEXT |
Windows NT |
CF_UNICODETEXT |
CF_TEXT |
Windows NT |
If the operating system provides an automatic type conversion for a particular clipboard format, there is no advantage to placing the conversion format(s) on the clipboard.
If the system provides an automatic type conversion for a particular clipboard format, and you call EnumClipboardFormats to enumerate the clipboard data formats, the operating system first enumerates the format that is on the clipboard, followed by the formats to which it can be converted.
If the clipboard contains data in the CF_PALETTE format, the application should use the SelectPalette and RealizePalette functions to realize any other data in the clipboard against that logical palette.
See SetClipboardData for further information on specific clipboard data formats.
EnumClipboardFormats, SetClipboardData, RealizePalette, SelectPalette