public override RespMessage checkReg(String registCode)
        {
            //相等且注册表没有存此值时,就存入
            RegistryKey fatherKey       = SoftRegister.getFatherKey();
            String      localRegistCode = this.generateRegistCode(SoftRegister.getMNum());
            string      str             = fatherKey.GetValue(ActivityConst.VALUE_NAME_FOR_VALIDATE_IN_REGISTRY, "").ToString();

            if (localRegistCode.Equals(registCode))
            {
                if ("".Equals(str))
                {
                    fatherKey.SetValue(ActivityConst.VALUE_NAME_FOR_VALIDATE_IN_REGISTRY, registCode);
                }
                return(new RespMessage(1, "OK"));
            }
            else
            {
                //当注册码不想等时,且当注册表此注册信息存在,也会被清除
                //string str = Registry.GetValue(Const.REGISTRY_LOCATION, Const.VALUE_NAME_FOR_VALIDATE_IN_REGISTRY, "").ToString();
                if (!"".Equals(str))
                {
                    //fatherKey.SetValue( Const.VALUE_NAME_FOR_VALIDATE_IN_REGISTRY, "");
                    fatherKey.DeleteValue(ActivityConst.VALUE_NAME_FOR_VALIDATE_IN_REGISTRY);

                    return(new RespMessage(2, "请重新输入注册码,以便继续使用应用"));
                }
                return(new RespMessage(3, "请输入正确的注册码!"));
            }
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.StartPosition = FormStartPosition.Manual;
            this.Text          = this.Text + "-版本" + ActivityConst.VERSION;
            this.textBox1.Text = SoftRegister.getMNum();
            RegistryKey fatherKey = SoftRegister.getFatherKey();

            this.textBox2.Text = fatherKey.GetValue(ActivityConst.VALUE_NAME_FOR_VALIDATE_IN_REGISTRY, "").ToString();

            this.Location = new Point((Screen.PrimaryScreen.Bounds.Width - this.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2);
            //Console.WriteLine("获取的机器码:" + SoftRegister.getMNum());
            //Console.WriteLine("生成的注册码:" + sr.generateRegistCode("BFEBFBFF000306C3D895FC2A"));
            //Console.WriteLine("生成的注册码2:" + sr.generateRegistCode(SoftRegister.getMNum()));
            //RespMessage respMessage = sr.checkReg(sr.generateRegistCode(SoftRegister.getMNum()));
            //Console.WriteLine("获取的注册信息:"+respMessage.message);

            //测试发邮件
            //Console.WriteLine("发送前");
            //MailTool email = new MailTool("*****@*****.**", "测试邮件2", "测试内容");
            //email.Send();
            //Console.WriteLine("发送没");

            //测试正则
            //Console.WriteLine("发送前");
            //Regex reg = new Regex(".*(\\[.*\\]).*");
            //Match m = reg.Match("kfjs[fds]jgj");
            //Console.WriteLine(m.Groups[1].Value);

            //Console.WriteLine("发送后");
        }