C# 通过注册表将子项添加到Windows上下文菜单(无外壳)

C# 通过注册表将子项添加到Windows上下文菜单(无外壳),c#,winforms,registry,C#,Winforms,Registry,我想在Windows上下文菜单中添加一个菜单项,然后为所述菜单添加两个子菜单。 我选择对文本文件进行测试,试图让两个子菜单都在记事本中简单地打开文本文件,但不幸的是,它不起作用 我的菜单根本没有添加到上下文菜单中,我无法找出问题所在,因为所有注册表项都创建得很好 我错过了什么 PS:在Windows 10上测试此功能,应用程序以管理员身份运行 我按照指南创建代码 using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("

我想在Windows上下文菜单中添加一个菜单项,然后为所述菜单添加两个子菜单。 我选择对文本文件进行测试,试图让两个子菜单都在记事本中简单地打开文本文件,但不幸的是,它不起作用

我的菜单根本没有添加到上下文菜单中,我无法找出问题所在,因为所有注册表项都创建得很好

我错过了什么

PS:在Windows 10上测试此功能,应用程序以管理员身份运行

我按照指南创建代码

    using (RegistryKey key = Registry.ClassesRoot.OpenSubKey(".txt", true))
    {
        using (RegistryKey subkey = key.CreateSubKey(@"Shell\TestText"))
        {
            subkey.SetValue("MUIVerb", "TestText");
            subkey.SetValue("SubCommands", "process1;process2");
            subkey.SetValue("Icon", "notepad.exe");

            using (RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64))
            {
                using (RegistryKey shell = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell", true))
                {
                    using (RegistryKey one = shell.CreateSubKey("process1"))
                    {
                        one.SetValue("", "Process 1");
                        one.CreateSubKey("command");
                        one.OpenSubKey("command", true).SetValue("", "notepad.exe \" % 1\"");
                    }

                    using (RegistryKey two = shell.CreateSubKey("process2"))
                    {
                        two.SetValue("", "Process 2");
                        two.CreateSubKey("command");
                        two.OpenSubKey("command", true).SetValue("", "notepad.exe \" % 1\"");
                    }
                }
            }                    
        }
    }