static void Init() { // 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.SetAppVersion("PASTE_YOUR_APP_VERION"); }
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(); } }
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; } }
private bool Init(string sourceFolder, out bool hasError, out int statusCode) { lock (balanceLock) { if (isInitted) { hasError = hasErrorInternal; statusCode = statusCodeInternal; return(true); } try { if (File.Exists("LexActivator.dll") == false) { try { File.Copy(Path.Combine(sourceFolder, "LexActivator_86.dll"), "LexActivator.dll", true); } catch (Exception ex) { logger.Error(ex, "LexActivator_86 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } var isDebug = false; isDebug = false; #if DEBUG isDebug = true; #endif #if LA_ANY_CPU try { if (File.Exists("LexActivator64.dll") == false) { File.Copy(Path.Combine(sourceFolder, "LexActivator_64.dll"), "LexActivator64.dll", true); } } catch (Exception ex) { logger.Error(ex, "LexActivator_64 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcp100_64.dll"), "msvcp100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcp100_64 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcr100_64.dll"), "msvcr100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcr100_64 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } #else if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcp100_86.dll"), "msvcp100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcp100_86 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcr100_86.dll"), "msvcr100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcr100_86 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } #endif try { if (File.Exists("Product.dat") == false) { File.Copy(Path.Combine(sourceFolder, "Product.dat"), "Product.dat", true); } } catch (Exception ex) { logger.Error(ex, "Product.dat copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } int setProductFile = 0; try { setProductFile = LexActivator.SetProductFile("Product.dat"); } catch (DllNotFoundException dllNotFoundException) { logger.Error(dllNotFoundException, $"SetProductFile error. Code: {setProductFile}"); logger.Error(dllNotFoundException.ToString()); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } catch (Exception ex) { logger.Error(ex, $"SetProductFile error. Code: {setProductFile}"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } if (setProductFile != LexActivator.StatusCodes.LA_OK) { logger.Error($"SetProductFile error. Code: {setProductFile}"); hasError = true; statusCode = setProductFile; statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(false); } var setProductId = LexActivator.SetProductId("f4a935cd-21ad-4bd2-8b5b-c929e0275340", LexActivator.PermissionFlags.LA_USER); if (setProductId != LexActivator.StatusCodes.LA_OK) { logger.Error($"SetProductId error. Code: {setProductFile}"); hasError = true; statusCode = setProductId; statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(false); } else { hasError = false; statusCode = setProductId; } //var licenseHelperReset = Reset(out int statusCodeReset); statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(true); } catch (Exception ex) { hasError = true; statusCode = 0; logger.Error(ex); } statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(false); } }