问题
I am interested in learning windows system internals and how things work. I am inclined towards learning system programming on windows. With that context, I am curious to know few things on how windows clipboard internally functions:
- What precisely happens when we select some text, image etc and press Ctrl + C ?
- What precisely happens when we we press Ctrl + V in different application?
- Where exactly the copied data resides? Does the copied data go into kernel mode memory - that is shared across all processes?
- How the copied data becomes available to a different process?
I want to know the answer to the above questions from the system programmer's perspective.
Also, share any resources that discuss about windows clipboard internals.
回答1:
I have some good resources on my site: http://www.clipboardextender.com It talks about clipboard viewer implementation, typical mistakes, do's and dont's.
Basically the clipboard is a shared memory area that you copy data into (aka. "copy", such as in response to the user pressing Ctrl+C) and copy data from (aka "paste"). The data can be simultaneously represented in dozens of common formats, and any number of programmer-defined formats.
It is impossible to completely "backup" the clipboard and restore it like it was, without impacting other programs, and causing a negative user experience. Look into "delayed rendering" to see why, and consider what would happen when an Excel user copies 5000 rows x 255 columns in a spreadsheet, and presses Ctrl+V. Understand that, and you'll understand the magic (and pitfalls) of delayed rendering.
来源:https://stackoverflow.com/questions/8171249/want-to-know-windows-clipboard-internals