问题
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