从C#上的Windows shell上下文菜单中获取多个文件(参数)
发布时间:2020-12-15 08:27:46 所属栏目:百科 来源:网络整理
导读:我正在编写一个C#应用程序,它将文件作为参数,我将它添加到 shell上下文菜单中,代码如下所示; if (((CheckBox)sender).CheckState == CheckState.Checked) { RegistryKey key = Registry.CurrentUser.OpenSubKey("SoftwareClasses*shell" + KEY_NAME
我正在编写一个C#应用程序,它将文件作为参数,我将它添加到
shell上下文菜单中,代码如下所示;
if (((CheckBox)sender).CheckState == CheckState.Checked) { RegistryKey key = Registry.CurrentUser.OpenSubKey("SoftwareClasses*shell" + KEY_NAME + "command"); if (key == null) { key = Registry.CurrentUser.CreateSubKey("SoftwareClasses*shell" + KEY_NAME + "command"); key.SetValue("",Application.ExecutablePath + " "%1""); } } else if (((CheckBox)sender).CheckState == CheckState.Unchecked) { RegistryKey key = Registry.CurrentUser.OpenSubKey("SoftwareClasses*shell" + KEY_NAME); if (key != null) { Registry.CurrentUser.DeleteSubKeyTree("SoftwareClasses*shell" + KEY_NAME); } 它运行良好,但如果我选择多个文件,则运行多个应用程序实例. 解决方法
检测
instance of your application is already是否在启动时运行.
如果是,请执行send the command line arguments to the running instance并退出新实例. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |