public bool setSerialNumber() { bool flag = false; try { Process proc = new Process(); proc.StartInfo = new ProcessStartInfo("cmd", "/c " + "wmic diskdrive get serialnumber"); proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; proc.StartInfo.RedirectStandardOutput = true; proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived); proc.Start(); flag = true; proc.BeginOutputReadLine(); proc.WaitForExit(); txtUser.Text = ToNumbers(StringSecurity.Encrypt(serialNumber, "9722505033")); if (devFlag) { MessageBox.Show(serialNumber); } } catch (Exception) { flag = false; } return(flag); }
private void Activation_Shown(object sender, EventArgs e) { this.Enabled = false; if (File.Exists(Application.ExecutablePath + ".act")) { String oa = File.GetCreationTime(Application.ExecutablePath).ToOADate().ToString(); String coa = File.ReadAllText(Application.ExecutablePath + ".act"); if (coa.Trim().Length != 0) { coa = StringSecurity.Decrypt(coa, "9722505033"); String[] arr = coa.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 3) { String foa = arr[0]; String user = arr[1]; String sn = arr[2]; String tmpStr = ToNumbers(StringSecurity.Encrypt(serialNumber, "9722505033")); if (oa.Equals(foa) && tmpStr.Equals(sn)) { Suc = true; Close(); return; } } } } this.Enabled = true; Visible = true; txtUser.Focus(); }
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show(this, "Internet connection error :: " + e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!e.Cancelled && e.Result != null) { if (e.Result.Contains(txtUser.Text + " ")) { StreamWriter sw = new StreamWriter(File.Open(Application.ExecutablePath + ".act", FileMode.Create)); double datetime = File.GetCreationTime(Application.ExecutablePath).ToOADate(); sw.WriteLine(StringSecurity.Encrypt(datetime.ToString() + "," + txtUser.Text.Trim() + "," + txtUser.Text.Trim(), "9722505033")); sw.Close(); Application.Restart(); } } btnCancel.Enabled = btnGo.Enabled = txtUser.Enabled = true; Cursor = Cursors.Default; }