public RegKeyInput() { InitializeComponent(); GetComputerData getComputerData = new GetComputerData(); AppliCode.Text = getComputerData.GetComputerID(); }
public bool CheckUsrKey(string UserKey) { DateTime dateTime = DateTime.Now; var Psh = new PasswordHasher(); //检查注册信息,如果未注册设定30天试用 PasswordHasher passwordHasher = new PasswordHasher(); GetComputerData getComputerData = new GetComputerData(); string protectid = getComputerData.GetHashProtectComputerID(); var Str = Psh.VerifyHashedPassword(UserKey, protectid); // 使用PASSWORDHASH 数值进行对比 if (Convert.ToBoolean(Str)) { RegOprate.WriteRegdit("Regkey", UserKey); return(true); } else { return(false); } }
private void RegRxSoft_Click(object sender, EventArgs e) { if (RegKey.Text.Trim() != string.Empty && RegKey.Text.Trim().Length == 68) { GetComputerData getComputerData = new GetComputerData(); var res = getComputerData.CheckUsrKey(RegKey.Text.Trim()); if (!res) { RegKey.Text = string.Empty; MessageBox.Show("注册码错误,请输入正确的注册码!"); } else { MessageBox.Show("注册码输入成功,请重启软件进行使用!"); Process.GetCurrentProcess().Kill(); System.Environment.Exit(0); } } else { RegKey.Text = "输入的为无效注册码!"; } }
private bool CheckUserAccess() { DateTime dateTime = DateTime.Now; var Psh = new PasswordHasher(); //检查注册信息,如果未注册设定30天试用 PasswordHasher passwordHasher = new PasswordHasher(); String protectid = String.Empty; if (RegOprate.IsRegeditExit("ProtectComputerID")) { protectid = RegOprate.GetRegValue("ProtectComputerID"); } if (String.IsNullOrEmpty(protectid)) { GetComputerData getComputerData = new GetComputerData(); protectid = getComputerData.GetHashProtectComputerID(); //重新获取ID RegOprate.WriteRegdit("ProtectComputerID", protectid); } protectid = protectid + "yeccdesignforruixiang2020"; if (RegOprate.IsRegeditExit("RegKey")) { string RegWord = RegOprate.GetRegValue("Regkey"); var Str = Psh.VerifyHashedPassword(RegWord, protectid); // 使用PASSWORDHASH 数值进行对比 if (Convert.ToBoolean(Str)) { HasAccessToRun = true; Yecc_Help.Enabled = false; Properties.Settings.Default.VisionType = "正式授权版"; return(true); } } //检查是否处于试用期 并小于30天 if (RegOprate.IsRegeditExit("SetUpTime")) { DateTime RegWord = Convert.ToDateTime(RegOprate.GetRegValue("SetUpTime")); DateTime NormalWorkTime = RegWord.AddDays(30); if (dateTime > NormalWorkTime) { Properties.Settings.Default.VisionType = "30天试用版"; MessageBox.Show("当前试用30天已过期,请申请正式版本!"); } else { //临时授权未过期 授权通过使用 TimeSpan WorkDays = NormalWorkTime - dateTime; Properties.Settings.Default.VisionType = "30天试用版,剩余[小时]: " + WorkDays.TotalHours.ToString("0"); HasAccessToRun = true; Yecc_Help.Enabled = true; return(true); } } else { //首次安装使用 string message = Properties.Resources.SoftAccess; string caption = "首次使用授权说明:"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { DateTime dateTime1 = dateTime; RegOprate.WriteRegdit("SetUpTime", dateTime1.ToString()); HasAccessToRun = true; Properties.Settings.Default.VisionType = "30天试用版"; return(true); } else { Process.GetCurrentProcess().Kill(); return(true); } } //非注册用户并试用时间已过期,强制退出 this.Hide(); Process[] AllProcess = Process.GetProcessesByName("RFTechnology"); if (AllProcess.Length == 1) { Process process = AllProcess[0]; string TitleName = process.MainWindowTitle; if (TitleName == "RegKeyInput") { MessageBox.Show("注册窗口您已打开,无需重复打开!"); return(false); } } RegKeyInput regKeyInput = new RegKeyInput(); regKeyInput.Show(); return(false); }