Beispiel #1
0
        private bool Work()
        {
            CookieContainer cookie = GetRemainClsCookie.GetCookie(txtNumber.Text, txtPwd.Text);

            //判断是否登陆成功
            if (GetRemainClsCookie.IsReady(cookie))
            {
                //成功
                //保存信息到注册表

                RegContral.SetValue("UserName", txtNumber.Text);
                RegContral.SetValue("UserPwd", txtPwd.Text);
                this.Hide();
                return(true);
            }
            else
            {
                //失败
                MessageBox.Show("登陆失败!");
                //更改按钮状态
                btnOK.Enabled     = true;
                txtNumber.Enabled = true;
                txtPwd.Enabled    = true;
                btnOK.Text        = "确认";
                this.Visible      = true;
                return(false);
            }
        }
Beispiel #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     //自启选项检查
     if (cbAutoRun.Checked)
     {
         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");
     }
     else
     {
         RegContral.SetValue("AutoRun", "0");
         try
         {
             RegistryKey key    = Registry.CurrentUser;
             RegistryKey SubKey = key.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion", true).CreateSubKey("Run");
             SubKey.DeleteValue("StduTools");
         }
         catch { }
     }
     //自退选项检查
     if (cbAutoExit.Checked)
     {
         RegContral.SetValue("AutoExit", "1");
         tmAutoExit.Enabled = true;
     }
     else
     {
         RegContral.SetValue("AutoExit", "0");
         tmAutoExit.Enabled = false;
     }
     //更新选项检查
     if (cbAutoUpdate.Checked)
     {
         RegContral.SetValue("AutoUpdate", "1");
         tmAutoExit.Enabled = true;
     }
     else
     {
         RegContral.SetValue("AutoUpdate", "0");
         tmAutoExit.Enabled = false;
     }
     this.Visible = false;
 }