private void button1_Click(object sender, EventArgs e) { RegistryKey MyReg0, RegGUIDFlag, RegFlag, RegValidGUIDDays, RegValidDays, RegStartGUIDDate, RegStartDate, RegPassword; MyReg0 = Registry.CurrentUser; //删除原有注册表项 MyReg0.DeleteSubKeyTree("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}", false); MyReg0.DeleteSubKeyTree("Software\\Aurora", false); try { RegGUIDFlag = MyReg0.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegFlag = MyReg0.CreateSubKey("Software\\Aurora"); RegValidGUIDDays = MyReg0.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegValidDays = MyReg0.CreateSubKey("Software\\Aurora"); RegStartGUIDDate = MyReg0.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegStartDate = MyReg0.CreateSubKey("Software\\Aurora"); RegFlag.SetValue("nRegFlag", "0"); RegValidDays.SetValue("nValidDays", "10"); RegGUIDFlag.SetValue("nRegGUIDFlag", "0"); RegValidGUIDDays.SetValue("nValidGUIDDays", "10"); RegStartGUIDDate.SetValue("StartGUIDDate", DateTime.Now.ToString("yyyy-MM-dd")); RegStartDate.SetValue("StartDate", DateTime.Now.ToString("yyyy-MM-dd")); RegPassword = MyReg0.CreateSubKey("Software\\Aurora\\Locker"); RegPassword.SetValue("Password", "000"); //Application.Restart(); } catch { } }
private void button1_Click(object sender, EventArgs e) { DialogResult dr = DialogResult.Yes; dr = MessageBox.Show("确定要重置注册表?", "Aurora智能提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { return; } strRC = CreateSNCode(); strInputKC = textBox1.Text; if (checkBox1.Checked == true) { strEnctr = EnText(strRC, DateTime.Now.Date.ToString("yyyy-MM-dd") + "hupo"); //学生版 if (transform(strEnctr, DateTime.Now.Date.ToString("yyyy-MM-dd") + "hupo") == strInputKC) { //调用外部程序导cmd命令行,实际上没Diao用 Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = false; p.Start(); //向cmd.exe输入command p.StandardInput.WriteLine("ipconfig"); p.StandardInput.WriteLine("exit"); //需要有这句,不然程序会挂机 RegistryKey MyReg, RegGUIDType, RegType, RegValidGUIDDays, RegValidDays, RegSuccess, RegCodeAllow, RegStartGUIDDate, RegStartDate; //声明注册表对象 MyReg = Registry.CurrentUser; //获取当前用户注册表项 try { RegGUIDType = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}");//在注册表项中创建子项 RegType = MyReg.CreateSubKey("Software\\Aurora"); RegValidGUIDDays = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegValidDays = MyReg.CreateSubKey("Software\\Aurora"); RegCodeAllow = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegSuccess = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegStartGUIDDate = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegStartDate = MyReg.CreateSubKey("Software\\Aurora"); RegType.SetValue("nRegFlag", "0"); RegValidDays.SetValue("nValidDays", "10"); //重置为初始 RegGUIDType.SetValue("nRegGUIDFlag", "0"); RegValidGUIDDays.SetValue("nValidGUIDDays", "10"); RegCodeAllow.SetValue("RegCodeAllow", "1"); RegSuccess.SetValue("RegSuccess", "false"); RegStartGUIDDate.SetValue("StartGUIDDate", DateTime.Now.ToString("yyyy-MM-dd")); RegStartDate.SetValue("StartDate", DateTime.Now.ToString("yyyy-MM-dd")); label1.Visible = true; label1.Text = "注册表信息已成功恢复初始设置,重启Aurora生效。"; label1.TextAlign = ContentAlignment.MiddleCenter; label1.ForeColor = Color.LawnGreen; } catch { } } else { label1.Visible = true; label1.Text = " 注册码输入错误。"; label1.TextAlign = ContentAlignment.MiddleCenter; label1.ForeColor = Color.Red; } } else { strEnctr = EnText(strRC, "ilovetangwei"); //商业版 if (transform(strEnctr, "ilovetangwei") == strInputKC) { //调用外部程序导cmd命令行,实际上没Diao用 Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = false; p.Start(); //向cmd.exe输入command p.StandardInput.WriteLine("ipconfig"); p.StandardInput.WriteLine("exit"); //需要有这句,不然程序会挂机 RegistryKey MyReg, RegGUIDType, RegType, RegValidGUIDDays, RegValidDays, RegSuccess, RegCodeAllow, RegStartGUIDDate, RegStartDate; //声明注册表对象 MyReg = Registry.CurrentUser; //获取当前用户注册表项 try { RegGUIDType = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}");//在注册表项中创建子项 RegType = MyReg.CreateSubKey("Software\\Aurora"); RegValidGUIDDays = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegValidDays = MyReg.CreateSubKey("Software\\Aurora"); RegCodeAllow = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegSuccess = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegStartGUIDDate = MyReg.CreateSubKey("Identities\\{D46B7C02-B796-4AAA-9D4F-2188CF2DBA30}"); RegStartDate = MyReg.CreateSubKey("Software\\Aurora"); RegType.SetValue("nRegFlag", "0"); RegValidDays.SetValue("nValidDays", "10"); //重置为初始 RegGUIDType.SetValue("nRegGUIDFlag", "0"); RegValidGUIDDays.SetValue("nValidGUIDDays", "10"); RegCodeAllow.SetValue("RegCodeAllow", "1"); RegSuccess.SetValue("RegSuccess", "false"); RegStartGUIDDate.SetValue("StartGUIDDate", DateTime.Now.ToString("yyyy-MM-dd")); RegStartDate.SetValue("StartDate", DateTime.Now.ToString("yyyy-MM-dd")); label1.Visible = true; label1.Text = "注册表信息已成功恢复初始设置,重启Aurora生效。"; label1.ForeColor = Color.LawnGreen; } catch { } } else { label1.Visible = true; label1.Text = " 注册码输入错误。"; label1.ForeColor = Color.Red; } } }