Example #1
0
 public static HardWareInfo GetInstance()
 {
     if (uniqueInstace == null)
     {
         lock (syncRoot)
         {
             if (uniqueInstace == null)
             {
                 uniqueInstace = new HardWareInfo();
             }
         }
     }
     return(uniqueInstace);
 }
Example #2
0
        private static string Validate()
        {
            string succ = "";

            try
            {
                RegistryKey rk                 = Registry.CurrentUser.OpenSubKey("Software\\KQRE\\LicenseInfo", true);
                string      machineCode        = rk.GetValue("MachineCode") as string;
                string      licenseNumber      = rk.GetValue("LicenseNumber") as string;
                string      plainString        = Decrypt(licenseNumber);
                string      currentMachineCode = HardWareInfo.GetInstance().GetMachineCode().Substring(0, 10);
                string[]    strs               = plainString.Split(" ".ToCharArray());
                if (strs.Length < 2)
                {
                    throw new LicenseException(typeof(Form), null, "序列号错误");
                }
                if (machineCode != currentMachineCode || machineCode != strs[0])
                {
                    throw new LicenseException(typeof(Form), null, "机器码错误");
                }
                if (IsExpire(strs[1]))
                {
                    throw new LicenseException(typeof(Form), null, "序列号已过期");
                }

                byte[] strBytes = Encoding.Unicode.GetBytes(DateTime.Now.ToString());
                rk.SetValue("LastRunTime", Convert.ToBase64String(strBytes));

                succ = "机器码:" + strs[0] + "\r过期时间:" + strs[1];
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(succ);
        }
Example #3
0
 public static HardWareInfo GetInstance()
 {
     if (uniqueInstace == null)
     {
         lock (syncRoot)
         {
             if (uniqueInstace == null)
             {
                 uniqueInstace = new HardWareInfo();
             }
         }
     }
     return uniqueInstace;
 }