public Launch() { InitializeComponent(); configManager = new ConfigManager(); startCheck = new StartCheck(configManager); startModeSet.IsChecked = startCheck.ifStart(); }
//设置开机自启 private void autoStart() { try { RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); //打开注册表项 if (key == null) //如果该项不存在的话,则创建该项 { key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); } if (startCheck.ifStart() == true) { key.SetValue("easyShot", AppDomain.CurrentDomain);//设置为开机启动 } else { key.DeleteValue("easyShot");//取消开机启动 } key.Close(); } catch (Exception ex) { Console.WriteLine(ex); } }