使用Clipboard.GetFileDropList的控制台应用程序:如何检查是否来自剪切或复制操作? [英] Console application using Clipboard.GetFileDropList: how to check if that came from a cut or copy operation?

查看:168
本文介绍了使用Clipboard.GetFileDropList的控制台应用程序:如何检查是否来自剪切或复制操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows资源管理器剪切/复制文件时,您可以获得该文件列表通过 Clipboard.GetFileDropList 方法。

When you cut/copy files from Windows Explorer, you can get that list of files through the Clipboard.GetFileDropList method.

如何确定该列表是来自剪切还是副本操作或通知另一方剪切/复制操作已完成?

How can you determine if that list came from a cut or copy operation or notify the other party that the cut/copy operation finished?

另一种方法:您可以使用以下命令将要剪切或复制的文件放在剪贴板上 Clipboard.SetFileDropList 方法。

The other way around: you can put files to be cut or copied on the clipboard using the Clipboard.SetFileDropList method.

如何指定要复制或剪切此列表?

How can you specify that this list is to be copied or cut?

这是关于控制台应用程序的,所以我无法监视Windows WM_CUT WM_COPY 消息如 C#文件-剪贴板中如何设置/读取哪个操作称为剪切或复制

This is about a console application, so I cannot monitor the Windows WM_CUT or WM_COPY messages as suggested by C# Files - in clipboard How to set/read which operation is called - Cut or Copy

推荐答案

您需要获取首选DropEffect格式的值(请参见 MSDN上的CFSTR_PREFERREDDROPEFFECT )。它包含一个 STGMEDIUM ,其 hGlobal 字段指向一个DWORD值。如果此值为 DROPEFFECT_COPY ,则为复制操作;如果它是 DROPEFFECT_MOVE ,则为剪切操作。

You need to get the value for the "Preferred DropEffect" format (see CFSTR_PREFERREDDROPEFFECT on MSDN). It contains a STGMEDIUM whose hGlobal field points to a DWORD value. If this value is DROPEFFECT_COPY, it's a copy operation; if it's DROPEFFECT_MOVE, it's a cut operation.

这篇关于使用Clipboard.GetFileDropList的控制台应用程序:如何检查是否来自剪切或复制操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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