如何从剪贴板清除指定的格式数据? [英] How to clear specified format data from clipboard?

查看:361
本文介绍了如何从剪贴板清除指定的格式数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我把一些数据放到剪贴板中,当我从剪贴板复制数据后,我想清除数据而不清除整个剪贴板。

I put some data into clipboard , after I copied data from the clipboard, I want to clear the data without clearing the entire clipboard.

/ p>

Something like that:

wchar_t* buf=NULL;
if( OpenClipboard(NULL)!=0)
{
HANDLE hData = GetClipboardData( CF_UNICODETEXT );
buf = (wchar_t*)GlobalLock( hData );
GlobalUnlock( hData );
CloseClipboard();
return buf;
} 

//job is done, and now I want to clear only hData!

据我所知,EmptyClipboard()会清空所有的东西!

As far as I understand, EmptyClipboard() will empty everything!

提前感谢!

推荐答案

剪贴簿只保存一个 IDataObject ;此数据对象可以呈现多种数据格式,但它只是一个COM对象。做你想做的事情的唯一方法是复制现有的数据对象(减去你希望删除的格式),并将其设置为剪贴板,而不是原来的。

The clipboard only holds a single IDataObject at one time; this data object can present multiple data formats but it is just a single COM object. The only way to do what you want would be to duplicate the existing data object (minus the format you wish to remove) and set that to the clipboard in place of the original.

这篇关于如何从剪贴板清除指定的格式数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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