2

i am looking from win32 APIs which would allow me to make a backup of the clipboard data (in memory/ file system) and later i can reset it using SetClipboardData.

i have seen the win32 API set and understand that OpenClipboard, getClipboardData and SetClipboardData would do the task for me. But i don't understand what format parameter to pass in GetClipboardData function, as i am unaware about the format and don't know any API either to get Format of the Clipboard data.

i want to support maximum possible formats, i know things like delay rendering and some private data types might not be possible to save. What could be the best way out, please suggest...


I am able to backup and restore the text content. how to do the same for Bitmap format. How to basically save the BITMAP in memory from its handle (fetched using GetClipboardData)

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
hjindal
  • 588
  • 7
  • 16

1 Answers1

1

Find the formats on the clipboard by calling EnumClipboardFormats(). Call GetClipboardData() to get a HGLOBAL that contains the clipboard data for a particular format. You can get the size of the memory by calling GlobalSize(). To read the memory wrapped by the HGLOBAL use GlobalLock() and GlobalFree().

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 2
    Some apps/formats require the use of `OleGetClipboard()` and `OleSetClipboard()` instead of `GetClipboardData()` and `SetClipboardData()`, so you should watch out for that. – Remy Lebeau Sep 27 '11 at 01:01
  • I am able to backup and restore the text content. how to do the same for Bitmap format. How to basically save the BITMAP in memory from its handle (fetched using GetClipboardData) – hjindal Oct 11 '11 at 12:21
  • There certainly is a way to do this but you need to ask that as a new question. – David Heffernan Oct 11 '11 at 12:38