private void Form1_Load(object sender, EventArgs e) { string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LAY3-T.lic"); 注册.Form1 form = new 注册.Form1(); if( !File.Exists(path)) { form.ShowDialog(); if (!File.Exists(path)) { this.Close(); return; } } StreamReader reader = new StreamReader(path); serialNum = reader.ReadLine(); machineNum = reader.ReadLine(); regNum = reader.ReadLine(); reader.Close(); if( !form.CheckRegHead(machineNum,regNum) ) { //这儿会对序列号正确性做简单校验,不合格的会有提示。以后再校验出问题就判定为恶意破解,不再有提示,直接修改系统运行结果。 MessageBox.Show("序列号不正确,系统将退出,请与软件供应商联系!"); this.Close(); } }
private void Form1_Load(object sender, EventArgs e) { //加密模块开始 string appPath = Application.StartupPath.ToString(); string licPath = appPath + "\\LAY3-T.lic"; 注册.Form1 form = new 注册.Form1(); if (!File.Exists(licPath)) { if (!File.Exists(licPath)) { this.Close(); return; } } //加密模块检查序列号 StreamReader reader = new StreamReader(licPath); machineNum = reader.ReadLine(); regNum = reader.ReadLine(); regTimes = reader.ReadLine(); regDate = reader.ReadLine(); serialNum = reader.ReadLine(); string licDate = reader.ReadLine(); string licQQ = reader.ReadLine(); reader.Close(); if (machineNum == null || regNum == null || regTimes == null || regDate == null || licDate == null || licQQ == null) { form.ShowDialog(); this.Close(); return; } licQQ = Decrypt(licQQ, "icdredge");//新写入 if (licQQ != "QQ-619498525") { MessageBox.Show("注册号不正确,系统将退出,请与软件供应商联系!"); this.Close(); return; } regNum = Decrypt(regNum, "icomicom"); machineNum = Decrypt(machineNum, "icomicom"); if (!CheckRegHead(machineNum, regNum)) { MessageBox.Show("序列号不正确,系统将退出,请与软件供应商联系!"); this.Close(); return; } licDate = Decrypt(licDate, "icdredge");//新写入 regDate = Decrypt(regDate, "icomicom"); DateTime trial = DateTime.Parse(licDate); DateTime YouregDate = DateTime.Parse(regDate); if (DateTime.Compare(trial, YouregDate) > 0) { MessageBox.Show("试用期限超出,系统将退出,请与软件供应商联系!"); this.Close(); return; } regTimes = Decrypt(regTimes, "icomicom"); long YouregTimes = Int64.Parse(regTimes); serialNum = Decrypt(serialNum, "icomicom"); if (YouregTimes == 0) { MessageBox.Show("试用次数超出,系统将退出,请与软件供应商联系!"); this.Close(); return; } else { if (File.Exists(licPath) == true) { File.Delete(licPath); } StreamWriter sw = File.CreateText(licPath); sw.WriteLine(Encrypt(machineNum, "icomicom")); sw.WriteLine(Encrypt(regNum, "icomicom")); sw.WriteLine(Encrypt((YouregTimes - 1).ToString(), "icomicom")); sw.WriteLine(Encrypt(regDate, "icomicom")); sw.WriteLine(Encrypt(serialNum, "icomicom")); DateTime dt = DateTime.Now; licDate = dt.ToString(); sw.WriteLine(Encrypt(licDate, "icdredge")); sw.WriteLine(Encrypt(licQQ, "icdredge")); sw.Flush(); sw.Close(); } }