how to reload saved “Embed Source” clipboard data?

2019-06-11 08:24发布

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条回答
闹够了就滚
2楼-- · 2019-06-11 09:04

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.

查看更多
登录 后发表回答