private bool CheckLicense()
        {
            var isLicenseGenuine = LexActivator.IsLicenseGenuine();

            if (isLicenseGenuine == LexActivator.StatusCodes.LA_OK)
            {
                Status = LicenseHelperStatusEnum.HaveLicense;
                GetLicenseInfo();
                return(true);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_SUSPENDED)
            {
                Status = LicenseHelperStatusEnum.LicenseSuspended;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_EXPIRED)
            {
                Status = LicenseHelperStatusEnum.LicenseExpired;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_GRACE_PERIOD_OVER)
            {
                Status = LicenseHelperStatusEnum.LicenseGracePeriodOver;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_FAIL)
            {
                Status = LicenseHelperStatusEnum.DontHaveLicense;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_PRODUCT_ID)
            {
                Status = LicenseHelperStatusEnum.WrongProductId;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_LICENSE_KEY)
            {
                Status = LicenseHelperStatusEnum.WrongProductKey;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME)
            {
                Status = LicenseHelperStatusEnum.ComputerClockError;
                return(false);
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME_MODIFIED)
            {
                Status = LicenseHelperStatusEnum.ComputerClockCracked;
                return(false);
            }
            else
            {
                Status = LicenseHelperStatusEnum.DontHaveLicense;
                return(false);
            }
        }
Example #2
0
        public ActivationForm()
        {
            InitializeComponent();
            int status;

            // status = LexActivator.SetProductFile ("ABSOLUTE_PATH_OF_PRODUCT.DAT_FILE");
            status = LexActivator.SetProductData("PASTE_CONTENT_OF_PRODUCT.DAT_FILE");
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                this.statusLabel.Text = "Error setting product file: " + status.ToString();
                return;
            }
            status = LexActivator.SetProductId("PASTE_PRODUCT_ID", LexActivator.PermissionFlags.LA_USER);
            if (status != LexActivator.StatusCodes.LA_OK)
            {
                this.statusLabel.Text = "Error setting product id: " + status.ToString();
                return;
            }
            // Setting license callback is recommended for floating licenses
            // status = LexActivator.SetLicenseCallback(LicenseCallback);
            // if (status != LexActivator.StatusCodes.LA_OK)
            // {
            // this.statusLabel.Text = "Error setting callback function: " + status.ToString();
            // return;
            // }
            status = LexActivator.IsLicenseGenuine();
            if (status == LexActivator.StatusCodes.LA_OK || status == LexActivator.StatusCodes.LA_EXPIRED || status == LexActivator.StatusCodes.LA_SUSPENDED || status == LexActivator.StatusCodes.LA_GRACE_PERIOD_OVER)
            {
                // uint expiryDate = 0;
                // LexActivator.GetLicenseExpiryDate(ref expiryDate);
                // int daysLeft = (int)(expiryDate - unixTimestamp()) / 86500;
                this.statusLabel.Text         = "License genuinely activated! Activation Status: " + status.ToString();
                this.activateBtn.Text         = "Deactivate";
                this.activateTrialBtn.Enabled = false;
                return;
            }
            status = LexActivator.IsTrialGenuine();
            if (status == LexActivator.StatusCodes.LA_OK)
            {
                uint trialExpiryDate = 0;
                LexActivator.GetTrialExpiryDate(ref trialExpiryDate);
                int daysLeft = (int)(trialExpiryDate - unixTimestamp()) / 86500;
                this.statusLabel.Text         = "Trial period! Days left:" + daysLeft.ToString();
                this.activateTrialBtn.Enabled = false;
            }
            else if (status == LexActivator.StatusCodes.LA_TRIAL_EXPIRED)
            {
                this.statusLabel.Text = "Trial has expired!";
            }
            else
            {
                this.statusLabel.Text = "Trial has not started or has been tampered: " + status.ToString();
            }
        }
Example #3
0
        public ActivationForm()
        {
            InitializeComponent();
            try
            {
                // LexActivator.SetProductFile ("ABSOLUTE_PATH_OF_PRODUCT.DAT_FILE");
                LexActivator.SetProductData("PASTE_CONTENT_OF_PRODUCT.DAT_FILE");
                LexActivator.SetProductId("PASTE_PRODUCT_ID", LexActivator.PermissionFlags.LA_USER);
                // LexActivator.SetLicenseCallback(LicenseCallback);

                int status = LexActivator.IsLicenseGenuine();
                if (status == LexStatusCodes.LA_OK || status == LexStatusCodes.LA_EXPIRED || status == LexStatusCodes.LA_SUSPENDED || status == LexStatusCodes.LA_GRACE_PERIOD_OVER)
                {
                    uint expiryDate = LexActivator.GetLicenseExpiryDate();
                    int  daysLeft   = (int)(expiryDate - unixTimestamp()) / 86400;
                    this.statusLabel.Text         = "License genuinely activated! Activation Status: " + status.ToString();
                    this.activateBtn.Text         = "Deactivate";
                    this.activateTrialBtn.Enabled = false;

                    // Checking for software release update
                    // LexActivator.CheckForReleaseUpdate("windows", "1.0.0", "stable", SoftwareReleaseUpdateCallback);
                    return;
                }
                status = LexActivator.IsTrialGenuine();
                if (status == LexStatusCodes.LA_OK)
                {
                    uint trialExpiryDate = LexActivator.GetTrialExpiryDate();
                    int  daysLeft        = (int)(trialExpiryDate - unixTimestamp()) / 86400;
                    this.statusLabel.Text         = "Trial period! Days left:" + daysLeft.ToString();
                    this.activateTrialBtn.Enabled = false;
                }
                else if (status == LexStatusCodes.LA_TRIAL_EXPIRED)
                {
                    this.statusLabel.Text = "Trial has expired!";
                }
                else
                {
                    this.statusLabel.Text = "Trial has not started or has been tampered: " + status.ToString();
                }
            }
            catch (LexActivatorException ex)
            {
                this.statusLabel.Text = "Error code: " + ex.Code.ToString() + " Error message: " + ex.Message;
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            try
            {
                Init();
                LexActivator.SetLicenseCallback(LicenseCallback);
                int status = LexActivator.IsLicenseGenuine();
                if (LexStatusCodes.LA_OK == status)
                {
                    Console.WriteLine("License is genuinely activated!");
                    uint expiryDate = LexActivator.GetLicenseExpiryDate();
                    int  daysLeft   = (int)(expiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400;
                    Console.WriteLine("Days left:" + daysLeft);

                    // Checking for software release update
                    // LexActivator.CheckForReleaseUpdate("windows", "1.0.0", "stable", SoftwareReleaseUpdateCallback);
                }
                else if (LexStatusCodes.LA_EXPIRED == status)
                {
                    Console.WriteLine("License is genuinely activated but has expired!");
                }
                else if (LexStatusCodes.LA_GRACE_PERIOD_OVER == status)
                {
                    Console.WriteLine("License is genuinely activated but grace period is over!");
                }
                else if (LexStatusCodes.LA_SUSPENDED == status)
                {
                    Console.WriteLine("License is genuinely activated but has been suspended!");
                }
                else
                {
                    int trialStatus;
                    trialStatus = LexActivator.IsTrialGenuine();
                    if (LexStatusCodes.LA_OK == trialStatus)
                    {
                        uint trialExpiryDate = LexActivator.GetTrialExpiryDate();
                        int  daysLeft        = (int)(trialExpiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400;
                        Console.WriteLine("Trial days left: " + daysLeft);
                    }
                    else if (LexStatusCodes.LA_TRIAL_EXPIRED == trialStatus)
                    {
                        Console.WriteLine("Trial has expired!");

                        // Time to buy the product key and activate the app
                        Activate();
                    }
                    else
                    {
                        Console.WriteLine("Either trial has not started or has been tampered!");
                        // Activating the trial
                        trialStatus = LexActivator.ActivateTrial(); // Ideally on a button click inside a dialog
                        if (LexStatusCodes.LA_OK == trialStatus)
                        {
                            uint trialExpiryDate = LexActivator.GetTrialExpiryDate();
                            int  daysLeft        = (int)(trialExpiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400;
                            Console.WriteLine("Trial days left: " + daysLeft);
                        }
                        else
                        {
                            // Trial was tampered or has expired
                            Console.WriteLine("Trial activation failed: " + trialStatus);
                        }
                    }
                }
            }
            catch (LexActivatorException ex)
            {
                Console.WriteLine("Error code: " + ex.Code.ToString() + " Error message: " + ex.Message);
            }
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        private void LexLicenseControl_Loaded(object sender, RoutedEventArgs e)
        {
            SpLicenseOk.Visibility               = Visibility.Collapsed;
            SpLicenseNoLicense.Visibility        = Visibility.Collapsed;
            SpLicenseError.Visibility            = Visibility.Collapsed;
            SpLicenseIsSuspended.Visibility      = Visibility.Collapsed;
            SpLicenseExpired.Visibility          = Visibility.Collapsed;
            SpTrialLicenseOk.Visibility          = Visibility.Collapsed;
            SpTrialLicenseIsSuspended.Visibility = Visibility.Collapsed;
            SpTrialLicenseExpired.Visibility     = Visibility.Collapsed;

            var isLicenseGenuine = LexActivator.IsLicenseGenuine();

            if (isLicenseGenuine == LexActivator.StatusCodes.LA_OK)
            {
                SpLicenseOk.Visibility = Visibility.Visible;
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_EXPIRED)
            {
                SpLicenseExpired.Visibility = Visibility.Visible;
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_SUSPENDED)
            {
                SpLicenseIsSuspended.Visibility = Visibility.Visible;
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_GRACE_PERIOD_OVER)
            {
                SpLicenseExpired.Visibility = Visibility.Visible;
            }
            else if (isLicenseGenuine == LexActivator.StatusCodes.LA_FAIL || isLicenseGenuine == LexActivator.StatusCodes.LA_E_PRODUCT_ID || isLicenseGenuine == LexActivator.StatusCodes.LA_E_LICENSE_KEY || isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME || isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME_MODIFIED)
            {
                SpLicenseError.Visibility = Visibility.Visible;
                ErrorCode.Text            = ((StatusCodesEnum)isLicenseGenuine).ToString();
            }
            else
            {
                var isTrialGenuine = LexActivator.IsTrialGenuine();
                if (isTrialGenuine == LexActivator.StatusCodes.LA_OK)
                {
                    uint trialExpiryDate    = 0;
                    var  getTrialExpiryDate = LexActivator.GetTrialExpiryDate(ref trialExpiryDate);
                    var  dtDateTime         = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
                    dtDateTime = dtDateTime.AddSeconds(trialExpiryDate).ToLocalTime();
                    //LexActivator.Reset();
                    SpTrialLicenseOk.Visibility = Visibility.Visible;
                }
                else if (isTrialGenuine == LexActivator.StatusCodes.LA_TRIAL_EXPIRED)
                {
                    SpTrialLicenseExpired.Visibility = Visibility.Visible;
                }
                else if (isTrialGenuine == LexActivator.StatusCodes.LA_SUSPENDED)
                {
                    SpTrialLicenseIsSuspended.Visibility = Visibility.Visible;
                }
                else
                {
                    SpLicenseNoLicense.Visibility = Visibility.Visible;
                }
                //SpLicenseError.Visibility = Visibility.Visible;
            }
        }