Example #1
0
        private bool CheckIfActivated()
        {
            try
            {
                if (!KeyHelper.MatchCurrentHardwareId(HWID_))
                {
                    log.Error("HWID changed");
                    return(false);
                }
                KeyValidator keyVal = new KeyValidator(Tmpl_);

                keyVal.SetKey(LicenseKey_);

                keyVal.SetValidationData("Email", Email_); // the key will not be valid if you set a different user name than the one you have set at key generation
                LicensingClient licensingClient = new LicensingClient(Tmpl_, LicenseKey_, keyVal.QueryValidationData(null), HWID_, ActivationKey_);
                if (licensingClient.IsLicenseValid())
                {
                    byte[] featureSet = keyVal.QueryKeyData("FeatureSet");
                    featureSet.ToString();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception E)
            {
                log.Error("Program is not activated", E);
                return(false);
            }
        }