everyone I have a problem with my application. I make an event that when I tick to a checkbox it will run when Window startup and I save this setting in a XML file. But it doesn't work and Window show me a message error "Stop working". Does anyone know what did I do wrong? I try to resolve it but it still. Thanks a lot. Here is my code:
private RegistryKey registrykeyApp = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
private void checkBoxKhoidongcungwin_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBoxKhoidongcungwin.Checked)
{
if(this.registrykeyApp.GetValue("ViKey") == null)
this.registrykeyApp.SetValue("ViKey", Application.ExecutablePath.ToString(),RegistryValueKind.ExpandString);
}
else
{
this.registrykeyApp.DeleteValue("ViKey", false);
}
}
Aucun commentaire:
Enregistrer un commentaire