private void frmNotice_Shown(object sender, EventArgs e) { //加载配置选项 if (!RegContral.IsKeyExit("AutoRun") || RegContral.GetKey("AutoRun") == "0") { cbAutoRun.Checked = false; } else { cbAutoRun.Checked = true; } if (!RegContral.IsKeyExit("AutoExit") || RegContral.GetKey("AutoExit") == "0") { cbAutoExit.Checked = false; } else { cbAutoExit.Checked = true; } if (!RegContral.IsKeyExit("AutoUpdate") || RegContral.GetKey("AutoUpdate") == "0") { cbAutoUpdate.Checked = false; } else { cbAutoUpdate.Checked = true; } //检查更新 if (cbAutoUpdate.Checked == true) { Thread t = new Thread(new ThreadStart(AutoUpdate)); } this.Visible = false; }
private void frmGetRemain_Load(object sender, EventArgs e) { //注册表有键值存在 if (RegContral.IsKeyExit("UserName") && RegContral.IsKeyExit("UserPwd")) { txtNumber.Text = RegContral.GetKey("UserName"); txtPwd.Text = RegContral.GetKey("UserPwd"); } else { //首次启动 //提示是否添加开机启动项 RegContral.SetValue("AutoUpdate", "1"); if (MessageBox.Show("是否添加到开机启动?(稍后可取消)", "提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { RegContral.SetValue("AutoRun", "1"); //设置开机启动项 //HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run RegistryKey key = Registry.CurrentUser; RegistryKey SubKey = key.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion", true).CreateSubKey("Run"); SubKey.SetValue("StduTools", Application.ExecutablePath + " -e"); } } }