private void onInstall(object sender, EventArgs e) { if (LicenseFile.Text == null || LicenseFile.Text == "") { MessageBox.Show("Please select valid license file", "Failed", MessageBoxButtons.OK); return; } try { String destFile = System.IO.Path.Combine(LicenseManager.LicenseDir, "license.lic"); // To copy a file to another location and // overwrite the destination file if it already exists. System.IO.File.Copy(LicenseFile.Text, destFile, true); LicenseManager.Validate(); if (LicenseManager.Valid) { MessageBox.Show("License installed and validated successfully", "Success", MessageBoxButtons.OK); this.Close(); } else { MessageBox.Show("License validation failed", "Failed", MessageBoxButtons.OK); } } catch { MessageBox.Show("License installation failed", "Failed", MessageBoxButtons.OK); } }
void timerTick(object sender, EventArgs e) { timer.Interval = interval; // validate license LicenseManager.Validate(); if (!LicenseManager.Valid) { MessageBox.Show("License validation failed", "Failed", MessageBoxButtons.OK); this.Close(); } }
public RequestLicenseForm() { InitializeComponent(); // get mac id String macId = LicenseManager.GetMacAddress(); if (macId != null) { HostId.Text = macId; } }
public static bool Validate() { IntPtr handle = RLM.rlm_init(LicenseManager.LicenseDir, ".", null); int stat = RLM.rlm_stat(handle); if (stat != 0) { Console.WriteLine("rlm_init returns " + stat); } else { Console.WriteLine("rlm_init successful"); // Check out a license IntPtr license = LicenseManager.Checkout(handle, LicenseManager.Product, LicenseManager.Version, LicenseManager.Count); stat = RLM.rlm_license_stat(license); Dictionary <string, string> licenseAttributes = new Dictionary <string, string>(); licenseAttributes["Product"] = LicenseManager.Product; licenseAttributes["Version"] = LicenseManager.Version; licenseAttributes["Expiry"] = RLM.marshalToString(RLM.rlm_license_exp(license)); licenseAttributes["Days Until Expiry"] = RLM.rlm_license_exp_days(license).ToString(); // Check it back in RLM.rlm_checkin(license); if (stat == 0) { LicenseManager.Valid = true; LicenseManager.showLicenseInfo(licenseAttributes); return(true); } else { LicenseManager.Valid = false; } } return(false); }
static void Main() { bool createdNew; Mutex m = new Mutex(true, "XcheckStudio-HubManager.exe", out createdNew); if (!createdNew) { MessageBox.Show("XcheckStudio-HubManager.exe is already running!", "Multiple Instances"); return; } /// Check license bool success = LicenseManager.Validate(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mainForm = new MainForm(); Application.Run(mainForm); }