如何重新加载已保存的“嵌入源”剪贴板数据?

时间:2022-04-25 09:43:35

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.

我试图与其他一些Windows应用程序进行交互,将剪贴板的转储保存到文件中。更准确地说,它在剪贴板中查找“嵌入源”格式,如果找到则将其保存到文件中。 “嵌入源”是一种基于OLE的格式,例如,当您从画笔复制图像时,会创建该格式。

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

在c#中我试过了

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.

其中data是一个包含文件字节的数组,但在将数据放在剪贴板上之前似乎要进一步包装它。

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

有人知道这样做的好方法(不一定是在C#中)吗?

Thanks, r

1 个解决方案

#1


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

解决之后,您需要将Clipboard.SetData传递给流对象,并且通过这样做,它不会将数据包装在另一种格式中。

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.

然而,一些元数据丢失了,因为画笔不允许你粘贴这样重新加载的数据,但这是另一个问题。

#1


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

解决之后,您需要将Clipboard.SetData传递给流对象,并且通过这样做,它不会将数据包装在另一种格式中。

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.

然而,一些元数据丢失了,因为画笔不允许你粘贴这样重新加载的数据,但这是另一个问题。