如何重新加载已保存的“嵌入源"剪贴板数据? [英] how to reload saved "Embed Source" clipboard data?

查看:104
本文介绍了如何重新加载已保存的“嵌入源"剪贴板数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

是否有一种方法可以将这些文件的内容重新加载到剪贴板中,以便可以将其粘贴回(例如画笔或任何Office程序中)?

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?

在C#中我尝试过

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

其中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.

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

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

谢谢, r

推荐答案

已解决,您需要向Clipboard.SetData传递一个流对象,这样做不会将数据包装为另一种格式.

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

            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.

这篇关于如何重新加载已保存的“嵌入源"剪贴板数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆