以编程方式调用SendTo [英] Programmatically call SendTo

查看:50
本文介绍了以编程方式调用SendTo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows资源管理器的SendTo上下文菜单选项中以编程方式(.net)调用命令?

How can I programmatically(.net) call a command on the Windows explorer SendTo context menu option?

推荐答案

sendto项是文件系统对象是一个实现细节,菜单由sendto shell扩展填充,并且可以扩展为包含其他内容.实际上,将sendto文件夹当作您可以使用单个参数执行的快捷方式文件夹以来,自Windows95以来一直存在问题(

The fact that sendto items are filesystem objects is a implementation detail, the menu is filled by the sendto shell extension and it could be extended to include other things in the next version of windows etc. In fact, treating the sendto folder as just a folder of shortcuts that you can execute with a single parameter has been problematic since Windows95 (powertoys/shell toys)

有些sendto项不是.lnk的,而是具有已注册投递处理程序(.DeskLink,.OtherFolder,.MAPIMail等)的唯一文件扩展名.

Some of the sendto items are not .lnk's but unique file extensions with a registered drop handler (.DeskLink, .OtherFolder, .MAPIMail etc)

记录的调用sendto项的方法是使用 IContextMenu .执行此操作的非托管方法是在要模拟sendto操作的对象上调用SHBindToParent(向IID_IShellFolder询问),然后调用 IContextMenu :: QueryContextMenu 填写HMENU,然后您必须找到sendto子菜单(我认为如果您使用IContextMenu :: GetCommandString询问它,它将返回sendto作为其动词)然后,您可以使用winapi菜单函数和/或IContextMenu :: GetCommandString枚举子菜单,以找到要调用的项目,然后调用 IContextMenu :: InvokeCommand

The documented way to invoke a sendto item would be to use IContextMenu. The un-managed way to do this would be to call SHBindToParent on the object you want to emulate the sendto action on (asking for IID_IShellFolder) Then call IShellFolder::GetUIObjectOf and ask for IID_IContextMenu, you can then call IContextMenu::QueryContextMenu to fill in a HMENU, you would then have to find the sendto submenu (I'm thinking it will return sendto as its verb if you ask it with IContextMenu::GetCommandString) You can then enumerate the submenu with the winapi menu functions and/or IContextMenu::GetCommandString to find the item you want to invoke, then call IContextMenu::InvokeCommand

这篇关于以编程方式调用SendTo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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