C# saving and then retriving data via the clipboard

爷,独闯天下 提交于 2019-12-06 14:06:56
E.J. Brennan

See this post, it might have what you need:

Strangeness with clipboard access

You cannot reliably restore the clipboard to its former state. Period. With simple formats, you may get away with it. When you get into more complex formats, particularly OLE and private formats, it's much more complicated. Read up on Delayed Rendering, and you'll realize the data isn't necessarily even ON THE CLIPBOARD YET. So when you request the data, so you can store it away, you're going to cause lengthy delays. Consider 5000 cells from Excel, which can be rendered into about 24 different formats, most of which are using delayed rendering (meaning that they're not really on the clipboard until you request data in a particular format, and then Excel has to generate it on-demand).
And even if you could, every time you restore the data, you're going to generate a clipboard update event that is going to be sent to all registered clipboard viewers, which will react to your shennanegans. In summary: Don't do it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!