views:

212

answers:

1

Hi all,

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

A: 

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.

r0u1i