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 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; } } //检查是否处于试用期 并小于30天 if (RegOprate.IsRegeditExit("SetUpTime")) { DateTime RegWord = Convert.ToDateTime(RegOprate.GetRegValue("SetUpTime")); DateTime dateTime1 = dateTime.AddDays(30); if (dateTime1 < RegWord) { Properties.Settings.Default.VisionType = "30天试用版"; MessageBox.Show("当前试用30天已过期,请申请正式版本!"); } else { //临时授权未过期 授权通过使用 Properties.Settings.Default.VisionType = "30天试用版"; HasAccessToRun = true; Yecc_Help.Enabled = true; return; } } 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; } else { Process.GetCurrentProcess().Kill(); return; } } //非注册用户并试用时间已过期,强制退出 this.Hide(); RegKeyInput regKeyInput = new RegKeyInput(); regKeyInput.Show(); }