Search code examples
windowsclipboard

In Windows, what actually is the clipboard?


This may sound like a silly question, but what actually is the clipboard?

My curiosity spiked after I noticed that the clipboard is used in more complex ways than I first thought possible. I thought the clipboard basically kept track of either a string of text, an image or a file and then simply would paste whatever if it had into the wherever the user specified if the context matched.

However, with word processing software like Microsoft Word I've noticed that you can copy and paste styles straight from websites and that on programs like Skype you can copy quotes that appear to be normal text in a Notepad document, but are actually formatted notes in Skype's UI.

I looked at the source code for a fake Skype quote generator, and it appears that there are multiple clipboards. Or is the clipboard laid out in a key-value type map?


Solution

  • There are multiple clipboard data formats and when you SetClipboardData you specify which format the data is. You can set multiple clipboard formats simultaneously because the clipboard is cleared explicitly with EmptyClipboard, You can also register your own custom formats to be used between your applications.

    The other side opens the clipboard, looks which formats there currently are, chooses the most appropriate one, and proceeds accordingly.