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) //确认 { RegistryKey MyReg1, RegPassword; MyReg1 = Registry.CurrentUser; RegPassword = MyReg1.CreateSubKey("Software\\Aurora\\Locker"); string strPassword = textBox3.Text; string strShowText = textBox4.Text; if (Flag1 == 1 && Flag2 == 1 && textBox3.Text != "") //将修改后的密码写入本地ini文件 { try { RegPassword.SetValue("Password", strPassword); } catch { } } if (textBox4 != null) { try { RegPassword.SetValue("ShowText", strShowText); } catch { } } this.Close(); }