示例#1
0
        private void RemoveTree()
        {
            var hive   = (RegistryHive)CurrentNode.Node.Tag;
            var target = CurrentNode.Node.Text;

            if (CurrentNode.Node.Parent == null)
            {
                return;
            }

            var targetNode = CurrentNode.Node;

            CurrentNode.SetNode(CurrentNode.Node.Parent);
            try
            {
                using (var key = RegistryHelpers.OpenKey(CurrentNode.Node.FullPath, hive,
                                                         RegistryKeyPermissionCheck.ReadWriteSubTree))
                {
                    key?.DeleteSubKeyTree(target);
                }
            }
            catch (Exception ex)
            {
                this.Msg(ex.Message, "Удаление раздела", icon: MessageBoxIcon.Error);
            }
            finally
            {
                targetNode.Remove();
            }
        }
示例#2
0
        public static void SetNode(TreeNode tree)
        {
            Node = tree;
            var hive = (RegistryHive)tree.Tag;
            var rk   = RegistryHelpers.OpenKey(tree.FullPath, hive);

            Regkey = rk;
        }
示例#3
0
        private void AddRoot()
        {
            var path = CurrentNode.Node.FullPath;
            var hive = (RegistryHive)CurrentNode.Node.Tag;

            try
            {
                using (var key = RegistryHelpers.OpenKey(path, hive, RegistryKeyPermissionCheck.ReadWriteSubTree))
                {
                    key?.CreateSubKey(NameTbox.Text, RegistryKeyPermissionCheck.ReadSubTree);
                }
            }
            catch (Exception ex)
            {
                this.Msg(ex.Message, "Ошибка", icon: MessageBoxIcon.Error);
                return;
            }
            int indexNewNode = CurrentNode.Node.Nodes.Add(NameTbox.Text, NameTbox.Text).Index;

            CurrentNode.Node.Nodes[indexNewNode].Tag = CurrentNode.Node.Tag;
            Close();
        }