Example #1
0
        static public ContextMenuKey CreateEmptyMenuKey(ContextMenuKey key)
        {
            if (key.IsMenu == true)
            {
                string[] tmpsub = key.RegistryKey.GetSubKeyNames();

                if (tmpsub.Length != 1)
                {
                    return(null);
                }
                else if (tmpsub[0] != "shell")
                {
                    return(null);
                }


                RegistryKey parent = key.RegistryKey;
                parent = parent.OpenSubKey("shell", true);
                string      name = GetUniqueName(parent, "Новое_меню");
                RegistryKey RKey = parent.CreateSubKey(name);
                RKey.SetValue("MUIVerb", (object)name);
                RKey.SetValue("SubCommands", (object)"");

                RKey.CreateSubKey("shell");

                return(new ContextMenuKey(RKey));
            }

            return(null);
        }
Example #2
0
        static public ContextMenuKey CreateEmptyKey(ContextMenuKey key)
        {
            if (key.IsMenu == true)
            {
                string[] tmpsub = key.RegistryKey.GetSubKeyNames();

                if (tmpsub.Length != 1)
                {
                    return(null);
                }
                else if (tmpsub[0] != "shell")
                {
                    return(null);
                }


                RegistryKey parent = key.RegistryKey;
                parent = parent.OpenSubKey("shell", true);
                string      name = GetUniqueName(parent, "Новый_ключ");
                RegistryKey RKey = parent.CreateSubKey(name);
                RKey.SetValue("MUIVerb", (object)name);

                Microsoft.Win32.RegistryKey command = RKey.CreateSubKey("command");
                command.SetValue("", EmptyCommand);

                return(new ContextMenuKey(RKey));
            }

            return(null);
        }
Example #3
0
        static public void ToStore(ContextMenuKey key, string FolderPath, bool DeleteFromRegistry = true)
        {
            if (key == null)
            {
                throw new Exception("Ключ не существует.");
            }

            if (!Directory.Exists(FolderPath))
            {
                throw new Exception("Директория для сериализации не существует.");
            }

            /*if (key.Disabled == true) {
             *  throw new Exception("Bad key.");
             * }*/


            string headerRegFile = "Windows Registry Editor Version 5.00\r\n;This file was generated by the 'MySimpleCM' program.\r\n\r\n";

            //запись
            byte[]     text     = Encoding.Unicode.GetBytes(headerRegFile + Serialize(key.RegistryKey));
            string     nameFile = key.GetHashCode().ToString();
            FileStream stream   = File.Create(FolderPath + "\\" + nameFile + ".reg");

            stream.Write(text, 0, text.Length);
            stream.Close();

            if (DeleteFromRegistry)
            {
                key.DeleteKey();
            }
        }
Example #4
0
        public void Reset()
        {
            ContextMenuKey tmp = new ContextMenuKey(this.RegistryKey);

            registryName = tmp.registryName;
            muiVerb      = tmp.muiVerb;
            icon         = tmp.icon;
            command      = tmp.command;
            extended     = tmp.extended;
            position     = tmp.position;

            CanSave = false;
            OnPropertyChanged("Title");
        }