如何在delphi中将项目添加到Windows资源管理器内容菜单?
我想在 Windows 资源管理器内容菜单中创建菜单项(适用于所有文件类型),单击后将打开我的应用程序并将所选文件名传递给它。有这方面的教程吗?我知道有 ShellPlus 组件可用,但它有点过时了。
I would like to create menu item in windows explorer content menu (for all file types) which after click will open my application and pass the selected file name to it. Is there any tutorial for this ? I know there is ShellPlus component available but it's a bit outdated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
注册表
此方法很简单,因为它归结为添加一些注册表项。缺点是你不能在其中添加任何逻辑。您可以在此处阅读相关内容以及< a href="https://stackoverflow.com/a/6285850/1242">这里是一个 Delphi 中的简单示例。如果使用 DDE 执行菜单项,您将获得更多控制权。有关 Delphi 示例,请参阅此处。
Shell 扩展
此方法需要更多工作,但您可以通过代码完全控制上下文菜单。您必须编写一个 DLL,实现 IContextMenu(或其他)并使用 Windows 资源管理器注册 dll。您可以在此处阅读相关内容。您已经提到了 Shell+。
Registry
This method is easy since it comes down to adding some registry keys. The downside is that you can't put any logic in it. You can read about it here and here a simple example in Delphi. You get a bit more control if you are using DDE to execute the menu items. See here for a Delphi example.
Shell Extension
This method is a bit more work, but you can completely control the context menu from code. You would have to write a DLL, implement IContextMenu (or others) and register the dll with Windows Explorer. You can read about it here. You already mentioned Shell+.
Delphi 包含一个用于 shell 扩展的演示项目。查看Demos\ActiveX\ShellExt 文件夹。
Delphi includes a demo project for shell extensions. Look in the Demos\ActiveX\ShellExt folder.
通过在注册表中为所需文件类型设置快捷菜单处理程序,可以独立于编程语言实现这一点。在那里,您可以使用正确的路径、正确的选项和正确的文件占位符来调用您的应用程序。
请参阅有关创建快捷菜单处理程序的 MSDN 文章了解更多详细信息。
This is possible independendly from the programming language by setting up shortcut menu handlers for the desired filetype(s) in the registry. There you can call your application with the correct path, the correct options and the right file-placeholders.
See the MSDN article on Creating Shortcut Menu Handlers for more detailled information.