/// <summary>Saves PC Information</summary> public static void SavePCInfo() { string hardInfo = GetHardwareInfo().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("|", ""); string infoFileName = hardInfo + ".hnf"; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = infoFileName; sfd.Filter = "Info|*.hnf"; if (STAShowDialog(sfd) == DialogResult.OK) { SoftwareKey.SaveHardwareInfo(sfd.FileName); } }
/// <summary>Checks if license is valid</summary> /// <param name="header">Module name</param> /// <param name="silent">Show save license file dialog? silent = true => does not show</param> /// <returns></returns> public static bool CheckLicense(string header, bool silent) { //check license bool validLicense = false; string licfilename = "info.hnflic"; string infoFileName = "info.hnf"; try { //public key string key = @"<RSAKeyValue><Modulus>7mBV5Z119MfeKS2goLOSHqbXN3rDbNt82E2Pm1C2NVbgFLNxchhxjoAFAuIYTPxH0DJg2KYKy48p6uiQGrlaFIEiuy+WEayOSfL6nJbGyffGfM0lUU//XHSwSuxinQS81UhoiTbiMUk/moBzASbsRDdCHKU1CiCJqt05amE0W2E=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"; SoftwareKey sk = new SoftwareKey(key); string[] files = Directory.GetFiles(Application.StartupPath, "*.hnflic"); //if (files.Length == 0) { //if no files are found, try to grab from server try { //using (WebClient client = new WebClient()) //{ // string licserverPath = "http://www.cmsoft.com.br/AudioSofts/PratiCanto/licensesv2/"; // string hardInfo = GetHardwareInfo().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)[1].Replace("|", ""); // licfilename = hardInfo + header + ".hnflic"; // infoFileName = hardInfo + header + ".hnf"; // string localFilename = Application.StartupPath + "\\" + licfilename; // string serverFilename = licserverPath + licfilename; // if (!File.Exists(localFilename)) //File.Delete(localFilename); // client.DownloadFile(serverFilename, localFilename); //} } catch { } files = Directory.GetFiles(Application.StartupPath, "*.hnflic"); } foreach (string s in files) { if (sk.LicenseCheck(s, header)) { validLicense = true; break; } } } catch { } if (!validLicense && !silent) { try { if (MessageBox.Show(lblFindLicenseTxt, "License", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Yes) { OpenFileDialog ofd = new OpenFileDialog(); ofd.FileName = licfilename; ofd.Filter = "Info|*.hnflic"; if (STAShowDialog(ofd) == DialogResult.OK) { FileInfo f = new FileInfo(ofd.FileName); File.Copy(ofd.FileName, Application.StartupPath + "\\" + f.Name + (f.Extension.ToLower() == ".hnflic" ? "" : ".hnflic")); Application.Exit(); return(false); } } else { if (MessageBox.Show(lblNotRegisteredTxt, "License", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Yes) { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = infoFileName; sfd.Filter = "Info|*.hnf"; if (STAShowDialog(sfd) == DialogResult.OK) { SoftwareKey.SaveHardwareInfo(sfd.FileName); } } } } catch { } Application.Exit(); return(false); } return(validLicense); }