private void simpleButton3_Click(object sender, EventArgs e) { try { if (txtSerial.Text == GetSerial.GetSerialNumber()) { string pathString; pathString = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"\dll\"; System.IO.Directory.CreateDirectory(pathString); System.IO.File.WriteAllBytes(pathString + "ver.txt", new byte[0]); TextWriter tw = new StreamWriter(pathString + "ver.txt"); tw.WriteLine(txtSerial.Text); tw.Close(); DateTime localDateTime = DateTime.Now; //bool test = false; //while (test == false) //{ // try // { // TcpClient client = new TcpClient(); // client.Connect("time.nist.gov", 13); // StreamReader streamReader = new StreamReader(client.GetStream()); // var response = streamReader.ReadToEnd(); // if (response.Length != 0) // { // var utcDateTimeString = response.Substring(7, 17); // localDateTime = DateTime.ParseExact(utcDateTimeString, "yy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); // test = true; // } // } // catch (Exception ee) // { // if (ee is SocketException || ee is IOException) { } // } //} Properties.Settings.Default.DateInisial = localDateTime; DateTime dt1 = localDateTime; TimeSpan oneDay = TimeSpan.FromDays(365); DateTime demain = dt1 + oneDay; Properties.Settings.Default.DateFinal = demain; Properties.Settings.Default.Save(); MessageBox.Show("ثم التفعيل بنجاح ", " البرنامج مفعل ... سينتهي البرنامج في " + DateExpiration.DateExpirationAvocaBine().ToString() + " "); } else { MessageBox.Show("الكود غير صحيح ، تأكد من الكود", "فشل المحاولة"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//Returns a game name, using PCSX2 database file public static string GetName(string _path) { string GameIndex = emuDir + @"\GameIndex.dbf"; var serial = ""; //Get the serial number of the game if (SupportedGames.ScrappingFiles.Any(a => _path.EndsWith(a))) { serial = GetSerial.GetSerialNumber(_path); } if (!string.IsNullOrWhiteSpace(serial)) { //Reads the GameIndex file by line using (var reader = new StreamReader(GameIndex)) { bool serialFound = false; while (!reader.EndOfStream) { var line = reader.ReadLine(); //Forges a GameIndex.dbf entry //If forged line appears in GameIndex.dbf stop and read the next line if (line.Contains("Serial = " + serial)) { serialFound = true; } //The next line which contains name associated with gameserial else if (serialFound) { //Cleans the data return(line.Replace("Name = ", String.Empty)); } } } } //We didn't find a name for the game, just return the file name return(Path.GetFileNameWithoutExtension(_path)); }
//Returns a game name, using PCSX2 database file public static string GetName(string _path) { string GameIndex = "./GameIndex.dbf"; var serial = ""; //Get the serial number of the game if (SupportedGames.ScrappingFiles.Any(a => _path.EndsWith(a))) { serial = GetSerial.GetSerialNumber(_path); } // See if serial is in file name, set if found if (string.IsNullOrWhiteSpace(serial)) { var fileName = Path.GetFileName(_path); var normalizedBuilder = new StringBuilder(fileName.ToUpperInvariant()); normalizedBuilder.Replace(".", string.Empty); normalizedBuilder.Replace("_", string.Empty); normalizedBuilder.Replace("-", string.Empty); normalizedBuilder.Replace(" ", string.Empty); var finalName = normalizedBuilder.ToString(); var serialMatch = GetRegions.regionList.FirstOrDefault(x => finalName.Contains(x)); if (serialMatch != null) { var result = Regex.Match(finalName, $"{serialMatch}[(0-9)]*"); if (result.Success) { serial = result.Value.Replace(serialMatch, serialMatch + "-"); } } } // Match serial to game database if (!string.IsNullOrWhiteSpace(serial)) { //Reads the GameIndex file by line using (var reader = new StreamReader(GameIndex)) { bool serialFound = false; while (!reader.EndOfStream) { var line = reader.ReadLine(); //Forges a GameIndex.dbf entry //If forged line appears in GameIndex.dbf stop and read the next line if (line.Contains("Serial = " + serial)) { serialFound = true; } //The next line which contains name associated with gameserial else if (serialFound) { //Cleans the data return(line.Replace("Name = ", String.Empty)); } } } } //We didn't find a name for the game, just return the file name return(Path.GetFileNameWithoutExtension(_path)); }