Ejemplo n.º 1
0
        public RegKeyInput()
        {
            InitializeComponent();
            GetComputerData getComputerData = new GetComputerData();

            AppliCode.Text = getComputerData.GetComputerID();
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 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 = "输入的为无效注册码!";
     }
 }
Ejemplo n.º 4
0
        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();
        }