public frmMain() { InitializeComponent(); shKeys2 = new ShellKeys2(); //sk2.delShellKey("40C2"); readKeys(); }
private void menuDelete_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) return; if (MessageBox.Show("Do you really want delete '" + comboBox1.SelectedItem.ToString() +"'", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2) == DialogResult.OK) { //Compact Framework keeps references to used registry keys although these have been closed explicitly in code //the following lines forces Compact Framework to dispose all used registry references //only after that we are able to delete the reg key shKeys2.Dispose(); shKeys2 = null; GC.Collect(); GC.WaitForPendingFinalizers(); if (ShellKeys2.delShellKey(comboBox1.SelectedItem.ToString())) MessageBox.Show("RegistryKey '" + comboBox1.SelectedItem.ToString()+"' has been deleted");//readKeys(); else MessageBox.Show("Sorry. Delete failed"); //reload the shellkeys2 object shKeys2 = new ShellKeys2(); readKeys(); } }
private void mnuAdd_Click(object sender, EventArgs e) { frmAddKey af = new frmAddKey(shKeys2.newKeysList); if (af.ShowDialog() == DialogResult.OK) { shKeys2.Dispose(); shKeys2 = new ShellKeys2(); readKeys(); } af.Dispose(); }