Exemplo n.º 1
0
        private void sectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView_registryKeys.SelectedNode;

            RegistryKey currentRegKey = Reg.GetRegistryKeyByName(selectedNode.Text, Data.regKeysList);

            if (currentRegKey != null)
            {
                sectionCreationForm sectionCreation = new sectionCreationForm();

                sectionCreation.ShowDialog();

                try
                {
                    RegistryKey newRegKey = currentRegKey.CreateSubKey(Data.newRegKeyName);

                    selectedNode.Nodes.Add(Data.newRegKeyName);
                }
                catch
                {
                    MessageBox.Show("Can't be proceed");
                }
                // добавить еще тип ключа (в виде дропбокса) и значение
            }
            else
            {
                MessageBox.Show("It's not possible to create new sections here");
            }
        }
Exemplo n.º 2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegistryKey currentRegKey = Reg.GetRegistryKeyByName(treeView_registryKeys.SelectedNode.Text, Data.regKeysList);

            if (currentRegKey != null)
            {
                // удаление параметра

                /*currentRegKey.DeleteValue("key1", false); // in case key doesn't exit an exeption won't appear
                 * currentRegKey.Close();*/
                try
                {
                    RegistryKey currentRegKeyParent = Reg.GetRegistryKeyByName(treeView_registryKeys.SelectedNode.Parent.Text, Data.regKeysList);

                    currentRegKey.Close();
                    currentRegKeyParent.DeleteSubKeyTree(treeView_registryKeys.SelectedNode.Text);

                    treeView_registryKeys.Nodes.Remove(treeView_registryKeys.SelectedNode);
                }
                catch { }
            }
            else
            {
                MessageBox.Show("It's not possible to delete this key");
            }
        }
Exemplo n.º 3
0
        private void button_parCreate_Click(object sender, EventArgs e)
        {
            Data.newParName  = textBox_parName.Text;
            Data.newParType  = (RegistryValueKind)Enum.Parse(typeof(Reg.RegistryValueKindNative), comboBox_parData.SelectedItem.ToString());
            Data.newParValue = textBox_parValue.Text;

            RegistryKey selRegKeyOpened = Reg.GetRegistryKeyByName(Data.selectedNode.Parent.Text, Data.regKeysList).OpenSubKey(Data.selectedNode.Text);

            selRegKeyOpened.SetValue(Data.newParName, Data.newParValue, Data.newParType);

            this.Close();
        }
Exemplo n.º 4
0
        private void parameterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Data.selectedNode = treeView_registryKeys.SelectedNode;

            RegistryKey currentRegKey = Reg.GetRegistryKeyByName(Data.selectedNode.Text, Data.regKeysList);

            if (currentRegKey != null)
            {
                parCreationForm parCreation = new parCreationForm();

                parCreation.ShowDialog();
            }
            else
            {
                MessageBox.Show("It's not possible to create new parameters here");
            }
        }
Exemplo n.º 5
0
        private void treeView_registryKeys_AfterSelect(object sender, TreeViewEventArgs e)
        {
            // showing selected key path

            TreeNode tempNode = treeView_registryKeys.SelectedNode;

            path.Clear();

            for (; ;)
            {
                path.Add(tempNode.Text);

                if (tempNode.Parent == null)
                {
                    break;
                }
                else
                {
                    tempNode = tempNode.Parent;
                }
            }

            textbox_path_str = "";

            path.Reverse();

            foreach (string tn in path)
            {
                textbox_path_str += tn + @"\";
            }

            textBox_path.Text = textbox_path_str;

            // showing name, type and value of selected key

            listView_regParData.Items.Clear();
            RegistryValueKind parType;
            object            parValue;
            String            parValueString;

            RegistryKey currentRegKey = Reg.GetRegistryKeyByName(treeView_registryKeys.SelectedNode.Text, Data.regKeysList);

            if (currentRegKey != null)
            {
                try
                {
                    foreach (string parName in currentRegKey.GetValueNames().OrderBy(x => x))
                    {
                        parValue = currentRegKey.GetValue(parName);
                        parType  = currentRegKey.GetValueKind(parName);

                        parValueString = (parType == RegistryValueKind.DWord) ? $"0x{((int)parValue).ToString("X2").ToLower().PadLeft(8, '0')} ({(uint)(int)parValue})" : parValue.ToString();

                        var parData = new string[] { parName, ((RegistryValueKindNative)parType).ToString(), parValueString };

                        var lvi = new ListViewItem(parData);
                        listView_regParData.Items.Add(lvi);
                    }
                }
                catch { }
            }
        }