资源管理器集成在上下文菜单中,但使用已运行的实例 [英] Explorer Integration in the Context Menu but using the already running instance

查看:232
本文介绍了资源管理器集成在上下文菜单中,但使用已运行的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查存在,如果不存在,请在资源管理器的右键单击(上下文)菜单中添加一些操作。

I want to check for the existence and if it doesn't exist add some actions in the Explorer's right click (context) menu.

除了上述要求之外(可以在网上轻松找到解决方案)我想再添加一个:

Besides of the above requirement (for which one can find easily solutions on web) I want to add one more:

假设我注册了以下命令:

Suppose that I register the following commands:


  • 命令#1 - 触发'C:\MyProg.exe / cmd1'

  • 命令#2 C:\MyProg.exe / cmd2'

...(aso。)

如何查看已经 MyProg.exe 的正在运行的实例,并将相应的命令/命令行参数 em>与用户点击的文件名?

How do I check if there is already a running instance of MyProg.exe and passing it the appropriate command/command line parameter together with the filename on which the user clicked?

(我想使用我的程序已经运行的实例来完成我的任务,而不是打开一个新的)

(IOW, I want to use the already running instance of my program to do my task and not to open a new one)

Delphi代码段将不胜感激。

A Delphi code snippet would be appreciated.

TIA

推荐答案

有两种方法可以将项目添加到上下文菜单中。

There are two ways to add items to the context menu.

注册表

这个方法很简单,因为它归结为添加一些注册表钥匙不利的是,你不能把任何逻辑。您可以阅读此处和<一个href =http://www.delphi3000.com/articles/article_4119.asp?SK= =nofollow noreferrer>这里一个Delphi中的一个简单例子。如果您使用DDE执行菜单项,您将得到更多的控制。有关Delphi示例,请参阅此处。如果DDE不能解决您的已经运行的问题,可以尝试通过某些IPC的方式让应用程序相互通信。

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. If DDE doesn't solve your 'already running' problem you could try and have your applications communicate with each other trough some way of IPC.

Shell Extension

这种方法有点多工作,但是您可以从代码中完全控制上下文菜单。你必须编写一个DLL,实现 IContextMenu (或其他),并使用Windows资源管理器注册该DLL。您可以阅读这里。您还可以查看 Shell +

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 could also check out Shell+.

这篇关于资源管理器集成在上下文菜单中,但使用已运行的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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