예제 #1
0
        /// <summary>
        /// Edits the value.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="valueName">Name of the value.</param>
        public static void EditStringValue(RegistryKey key, string valueName)
        {
            RegistryStringValueForm form = new RegistryStringValueForm();

            form.Text = "Value of:" + valueName;

            form.textBox1.Text = (string)key.GetValue(valueName);

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //key.(new RegistrySecurity());
            Registry.SetValue(key.Name, valueName, form.textBox1.Text, RegistryValueKind.String);
        }
예제 #2
0
        /// <summary>
        /// Handles the DoubleClick event of the tvObj control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void tvObj_DoubleClick(object sender, EventArgs e)
        {
            if (SelectedNode == null)
            {
                return;
            }

            if (SelectedKey == null)
            {
                TreeNode    node = SelectedNode;
                RegistryKey key  = (RegistryKey)node.Parent.Tag;

                switch (key.GetValueKind(node.Name))
                {
                case RegistryValueKind.String:
                    RegistryStringValueForm.EditStringValue(key, node.Name);
                    break;

                case RegistryValueKind.ExpandString:
                    break;

                case RegistryValueKind.Binary:
                    break;

                case RegistryValueKind.DWord:
                    RegistryStringValueForm.EditDWORDValue(key, node.Name);
                    break;

                case RegistryValueKind.MultiString:
                    break;

                case RegistryValueKind.QWord:
                    break;

                case RegistryValueKind.Unknown:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Edits the DWORD value.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="valueName">Name of the value.</param>
        public static void EditDWORDValue(RegistryKey key, string valueName)
        {
            RegistryStringValueForm form = new RegistryStringValueForm();

            form.Text = "Value of:" + valueName;

            form.textBox1.Text = key.GetValue(valueName).ToString();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            int value;

            if (!int.TryParse(form.textBox1.Text, out value))
            {
                return;
            }
            Registry.SetValue(key.Name, valueName, value, RegistryValueKind.DWord);
        }