private void btn_importLic_Click(object sender, EventArgs e) { Form_License licForm = new Form_License(); licForm.Show(); //if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) //{ // try // { // if (MessageBox.Show("Application will close after importing the license\nClick OK to continue", "Application will close!", MessageBoxButtons.OK, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) // { // string fileName = openFileDialog1.FileName; // string name = openFileDialog1.SafeFileNames[0].Remove(openFileDialog1.SafeFileNames[0].Length - 4, 4); // HashPass.WriteToReg(name); // string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows); // string newFileName = Path.Combine(winPath, "clc.clc"); // if (File.Exists(newFileName)) // File.Delete(newFileName); // File.Move(fileName, newFileName); // MessageBox.Show("License imported!"); // HashPass.CheckLicense(); // refreshLicInfo(); // } // } // catch // { // MessageBox.Show("License import error!"); // } //} }
private void CheckLicense() { HashPass.refreshLicInfo(); //if (isLicError == true) // Application.Exit(); string winPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows); string licPath = Path.Combine(winPath, "clc.clc"); if (File.Exists(licPath) && HashPass.isExpired != true) { string licType = HashPass.CheckLicense(); if (licType == "error") { label_WrongPass.Show(); label_WrongPass.Text = "License read error!"; txtBx_Pass.Enabled = false; isLicError = true; //Application.Exit(); } else if (licType == "n") { label_WrongPass.Show(); label_WrongPass.Text = "Invalid License!"; txtBx_Pass.Enabled = false; isLicError = true; //Application.Exit(); } else if (licType == "t" || licType == "p") { isLicError = false; txtBx_Pass.Enabled = true; HashPass.LicType = licType; } } else { txtBx_Pass.Enabled = false; if (HashPass.isExpired == true) { this.TopMost = false; MessageBox.Show("Your license is expired!"); label_WrongPass.Show(); label_WrongPass.Text = "License Expired!"; } Form_License frmLic = new Form_License(); this.TopMost = false; frmLic.ShowDialog(); } }