how to reload saved “Embed Source” clipboard data?

匆匆过客 提交于 2020-01-03 06:05:07

问题


some other windows application I'm trying to interface with, saves a dump of the clipboard to file. To be more precise, it looks for the "Embed Source" format in the clipboard, and if found saves it to file. "Embed Source" is some OLE based format, which is created, for example, when you copy an image from paintbrush.

Is there a way to reload the content of those files back to the clipboard, so I could paste them back in say, paintbrush or any office program?

In c# I've tried

System.Windows.Forms.Clipboard.SetData("Embed Source", data);

where data is an array containing the file's bytes, but it seems to wrap it further, before placing the data on the clipboard.

Does someone know of a good way to do so (not necessarily in C#)?

Thanks, r


回答1:


Solved, you need to pass Clipboard.SetData a stream object, and by doing so, it does not wrap the data within another format.

i.e.

            System.IO.FileStream s = System.IO.File.Open("c:\\temp\\dxf.ole",System.IO.FileMode.Open);

        Clipboard.SetData("Embed Source", s);

        s.Close();

Yet, some metadata is lost, since paintbrush doesn't let you paste such reloaded data, but that's another question.



来源:https://stackoverflow.com/questions/1025816/how-to-reload-saved-embed-source-clipboard-data

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