private void ViewValues(RegistryKey key) { KeysView.Rows.Clear(); // Очищаем список ключей string[] arrayValueNames; try // Проверяем, что есть доступ { arrayValueNames = key.GetValueNames(); } catch { this.Msg("Нет доступа"); return; } var collection = new DataGridViewRow[arrayValueNames.Length]; for (var index = 0; index < arrayValueNames.Length; index++) { var value = arrayValueNames[index]; var keyKind = key.GetValueKind(value); RegistryHelpers.ParseKeyValue(keyKind, key, value, out var keyValue, out var icon); collection[index] = new DataGridViewRow(); collection[index].CreateCells(KeysView, new object[] { icon, value, keyKind, keyValue }); } KeysView.Rows.AddRange(collection.ToArray()); }
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(); } }
public static void SetNode(TreeNode tree) { Node = tree; var hive = (RegistryHive)tree.Tag; var rk = RegistryHelpers.OpenKey(tree.FullPath, hive); Regkey = rk; }
private void NewRootBtn_Click(object sender, EventArgs e) { var roots = new Roots(false); var result = roots.ShowDialog(); if (result == DialogResult.OK) { RegistryHelpers.AddSubkeys(CurrentNode.Node); } }
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(); }
private void RootsTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) { RegistryHelpers.AddSubkeys(e.Node); }