从C#上的Windows shell上下文菜单中获取多个文件(参数)

我正在编写一个C#应用程序,它将文件作为参数,我将它添加shell上下文菜单中,代码如下所示;
if (((CheckBox)sender).CheckState == CheckState.Checked)
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes\\*\\shell\\" + KEY_NAME + "\\command");

                if (key == null)
                {
                    key = Registry.CurrentUser.CreateSubKey("Software\\Classes\\*\\shell\\" + KEY_NAME + "\\command");
                    key.SetValue("",Application.ExecutablePath + " \"%1\"");
                }
            }
            else if (((CheckBox)sender).CheckState == CheckState.Unchecked)
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes\\*\\shell\\" + KEY_NAME);

                if (key != null)
                {
                    Registry.CurrentUser.DeleteSubKeyTree("Software\\Classes\\*\\shell\\" + KEY_NAME);
                }

它运行良好,但如果我选择多个文件,则运行多个应用程序实例.
例如,如果我选择5个文件5应用程序正在打开,我该如何解决这个问题?

解决方法

检测 instance of your application is already是否在启动时运行.

如果是,请执行send the command line arguments to the running instance退出新实例.

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...