Exemplo n.º 1
0
        public DWordQWordEditor(cRegValue value) : base(value)
        {
            InitializeComponent();
            string data;

            if (value.Kind.Equals(RegistryValueKind.DWord))
            {
                data = ((int)value.Data).ToString("x");
                numericTextBox.Text = data;
            }
            else
            {
                data = ((long)value.Data).ToString("x");
                numericTextBox.Text = data;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 右侧ListView双击事件
        /// </summary>
        internal static void OnListViewDoubleClickAction()
        {
            if (MainForm.main.listView_Registry.SelectedItems.Count.Equals(1))
            {
                cRegValue value = (cRegValue)MainForm.main.listView_Registry.SelectedItems[0].SubItems[2].Tag;
                if (value.ParentKey != null)
                {
                    Registry_ValueEditor editor = null;

                    switch (value.Kind)
                    {
                    case RegistryValueKind.String:
                    case RegistryValueKind.ExpandString:
                        editor = new StringEditor(value);
                        break;

                    case RegistryValueKind.Binary:
                        editor = new BinaryEditor(value);
                        break;

                    case RegistryValueKind.DWord:
                    case RegistryValueKind.QWord:
                        editor = new DWordQWordEditor(value);
                        break;

                    case RegistryValueKind.MultiString:
                        editor = new MultiStringEditor(value);
                        break;

                    case RegistryValueKind.Unknown:
                    case RegistryValueKind.None:
                        break;

                    default:
                        break;
                    }

                    if (editor != null)
                    {
                        if (editor.ShowDialog(MainForm.main) == DialogResult.OK)
                        {
                            RefreshValues();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 将VALUE添加到ListViewItem中
        /// </summary>
        /// <param name="key"></param>
        /// <param name="regValue"></param>
        /// <returns></returns>
        internal static ListViewItem AddValueToListViewItem(RegistryKey key, cRegValue regValue)
        {
            // 添加名称到ListView,并且获取其ListViewItem进行操作
            ListViewItem lvi = MainForm.main.listView_Registry.Items.Add(regValue.Name);

            // 根据regValue的种类定位图片索引
            lvi.ImageKey = GetValueTypeIcon(regValue.Kind);
            // 绑定相关属性
            lvi.Name = regValue.Name;
            lvi.Tag  = key;
            // 填充数据的类型到LsitViewItem
            lvi.SubItems.Add(regValue.Kind.ToDataType());
            // 填充VAULUE的DATA到LsitViewItem,然后转换为ListViewSubItem
            ListViewItem.ListViewSubItem lvsi = lvi.SubItems.Add(regValue.ToString());
            // 绑定相关属性
            lvsi.Tag = regValue;
            return(lvi);
        }
Exemplo n.º 4
0
        // 注册表ListView编辑完成时间
        private void listView_Registry_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            MainForm.main.listView_Registry.LabelEdit = false;
            ListViewItem lvi       = MainForm.main.listView_Registry.Items[e.Item];
            string       valueName = e.Label == null ? lvi.Text : e.Label;

            try
            {
                RegistryKey readOnlyKey = lvi.Tag as RegistryKey;
                RegistryKey key         = cRegKey.Parse(readOnlyKey.Name, true).Key;
                cRegValue   value       = lvi.SubItems[2].Tag as cRegValue;
                key.SetValue(valueName, value.Data, value.Kind);
                lvi.Name            = valueName;
                lvi.SubItems[2].Tag = new cRegValue(readOnlyKey, valueName);
            }
            catch
            {
                lvi.Remove();
                MessageBox.Show("[x_x]:" + Common.CommonFunction.GetLastError32());
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 读取当前键获取VALUES
        /// </summary>
        /// <param name="key"></param>
        internal static void LoadValues(RegistryKey key)
        {
            // 状态栏显示当前操作的键路径
            MainForm.main.toolStripStatusLabel_Registry.Text = key.Name;
            // 初始化右侧ListView
            MainForm.main.listView_Registry.Items.Clear();
            // 获取KEY中的VALUE,并且保存到List中
            List <cRegValue> values = GetValues(key);

            // 判断values是否有效
            if (!values.Equals(null))
            {
                // 如果VALUES数目为0,则默认添加一个默认空值
                if (values.Count.Equals(0))
                {
                    AddValueToListViewItem(key, new cRegValue(String.Empty, RegistryValueKind.String, "(value not set)"));
                }
                else
                {
                    MainForm.main.listView_Registry.SuspendLayout();
                    // 每一项VALUE前面都需要添加一个默认值
                    cRegValue defaultValue = new cRegValue(String.Empty, RegistryValueKind.String, "(value not set)");
                    if (values.SingleOrDefault((val) => val.Name == defaultValue.Name) == null)
                    {
                        AddValueToListViewItem(key, defaultValue);
                    }

                    foreach (cRegValue v in values)
                    {
                        AddValueToListViewItem(key, v);
                    }

                    MainForm.main.listView_Registry.ResumeLayout();
                }
            }
        }
Exemplo n.º 6
0
 public BinaryEditor(cRegValue value) : base(value)
 {
     InitializeComponent();
     byteProvider             = new DynamicByteProvider((byte[])value.Data);
     byteTextBox.ByteProvider = byteProvider;
 }
Exemplo n.º 7
0
 public MultiStringEditor(cRegValue value) : base(value)
 {
     InitializeComponent();
     multiStringTextBox.Text = string.Join("\r\n", ((string[])value.Data));
 }
Exemplo n.º 8
0
 public Registry_ValueEditor(cRegValue value) : this()
 {
     Value            = value;
     txtName.Text     = value.Name;
     txtName.Modified = false;
 }
Exemplo n.º 9
0
 public StringEditor(cRegValue value) : base(value)
 {
     InitializeComponent();
     textBox.Text = value.Data.ToString();
 }