Esempio n. 1
0
 public static void Registration(string SN, string licenseCode)
 {
     try
     {
         string         s1 = SecurityHelper.DESDecrypt(licenseCode);
         SecurityHelper se = new SecurityHelper();
         string         s2 = se.Decrypt3DESString(SN, licenseCode.Substring(3, 32));
         if (s2 != SecurityHelper.MD5String16(SoftRegHelper.machineCode) || s1 != SoftRegHelper.machineCode)
         {
             throw new Exception("请购买正版获取序列号和授权码!");
         }
         RegistryHelper registry = new RegistryHelper(CommonHelper.SoftwareName);
         if (!registry.IsRegeditExit("IsAuthorization"))
         {
             registry.WTRegedit("IsAuthorization", SecurityHelper.DESEncrypt("TRUE"));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("软件注册失败:" + ex.Message);
     }
 }
Esempio n. 2
0
 private void  Registration(string softWareRegCode)
 {
     try
     {
         RegistryHelper registry      = new RegistryHelper(CommonHelper.SoftwareName);
         bool           IsAllowTryUse = CommonHelper.IsAllowTryUse;//软件是否试用
         if (IsAllowTryUse)
         {
             DateTime SetupTime = new DateTime();
             if (!registry.IsRegeditExit("SetupTime"))
             {
                 registry.WTRegedit("SetupTime", SecurityHelper.DESEncrypt(DateTime.Now.AddDays(+30).Date.ToString()));
             }
             SetupTime = SecurityHelper.DESEncrypt(registry.GetRegistData("SetupTime").ToString()).ToDate();;
             if (DateTime.Now > SetupTime)
             {
                 throw new Exception("您的试用期已过,请购买正版!");
             }
         }
         else
         {
             string code = SecurityHelper.DESEncrypt(softWareRegCode);
             if (!registry.IsRegeditExit("IsAuthorization"))
             {
                 registry.WTRegedit("IsAuthorization", SecurityHelper.DESEncrypt("TRUE"));
             }
             else if (code != SoftRegHelper.machineCode)
             {
                 throw new Exception("授权码错误,请购买正版获取授权码!");
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }