public RegistryKeyListControl() { this.InitializeComponent(); this.collection = new RegistryKeyCollection(); this.uniqueKeyNames = new List<string>(); }
public RegistryKeyListControl() { this.InitializeComponent(); this.collection = new RegistryKeyCollection(); this.uniqueKeyNames = new List <string>(); }
private void listView2_SelectedIndexChanged(object sender, EventArgs e) { bool itemSelected = this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0; this.btnIncludeEdit.Enabled = itemSelected; this.btnIncludeDelete.Enabled = itemSelected; RegistryKey selectedKey = null; if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { var lvi = this.listView2.SelectedItems[0]; if (lvi != null && lvi.Tag != null) { selectedKey = lvi.Tag as RegistryKey; } } if (selectedKey != null) { this.registryKeyValueListControl1.Items = selectedKey.Values; } else { this.registryKeyValueListControl1.Items = null; } }
private void btnIncludeDelete_Click(object sender, EventArgs e) { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { var lvi = this.listView2.SelectedItems[0]; if (lvi != null) { var rule = lvi.Tag as RegistryKey; var inheritedRule = lvi.Tag as InheritedVariableContainer; if (rule != null) { var dialogResult = MessageBox.Show( this, "Are you sure you want to delete this key?", "Delete key", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (dialogResult == DialogResult.Yes) { this.collection.Remove(rule.Name); this.listView2.Items.Remove(lvi); } } else if (inheritedRule != null) { var message = "The variable you have selected is inherited from a parent or the " + "global profile and cannot be deleted from this profile."; MessageBox.Show( this, message, this.btnIncludeDelete.Text); return; } else { this.listView2.Items.Remove(lvi); } this.Items = this.Items; } } }
// Methods private void ExecuteRegistryTests() { // Clear the list before starting RegistryKeyCollection.Clear(); // Get the base key from user input string basekey = Key; // Initialize results output for Reg.RegistryGetSubKeyNames() string DisplayName = string.Empty; // Initialize results output for Reg.RegistryGetLocalMachineValue() List <string> SubkeysList = new List <string>(); // Only modify / add items to the binding list if sub-keys exist under the specified base key if (Okuma.Scout.Reg.RegistryGetSubKeyNames(basekey, out SubkeysList)) { // Iterate through the output results foreach (string subkey in SubkeysList) { // Combine the base key and sub key to check for a value // Do not escape the string literal or extra slashes will be added (for example: @"\\") string newkey = basekey + "\\" + subkey; // For the purpose of filling the DataGridView, the value "DisplayName" is explicitly specified if (Okuma.Scout.Reg.RegistryGetLocalMachineValue(newkey, "DisplayName", out DisplayName)) { // If a Value for "DisplayName" exists under the new key, add it to the binding list RegistryKeyCollection.Add(new Subkeys(DisplayName, subkey)); } else { // Otherwise, leave it blank and just add the sub-key RegistryKeyCollection.Add(new Subkeys(string.Empty, subkey)); } } } }
private void Add(RegistryKey rule) { this.collection.Add(rule); this.Items = this.Items; }
private void AddToCabwiz(Cabwiz.InformationFile inf, BuildProfile profile, RegistryKeyCollection registryKeys) { if (inf == null) { throw new ArgumentNullException("inf"); } if (registryKeys != null) { foreach (var registryKey in registryKeys) { this.AddToCabwiz(inf.AddReg, registryKey); } } }