private void btnReg_Click(object sender, System.EventArgs e) { //读硬盘的序列号 string str_SerialNumber; HardDiskInfo hdd = AtapiDevice.GetHddInfo(0); // 第一个硬盘 str_SerialNumber = hdd.SerialNumber.ToString(); DESEncryptor dese1 = new DESEncryptor(); dese1.InputString = str_SerialNumber; dese1.EncryptKey = "lhgynkm0"; dese1.DesEncrypt(); string miWen = dese1.OutString; dese1 = null; err = null; string strresult = cs.Register(miWen, SysInitial.LocalDeptName, SysInitial.CurOps.strOperName, out err); if (strresult == "connection") { MessageBox.Show("中心数据库连接失败,请检查网再重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { MessageBox.Show("注册申请已经发送至中心,请等待注册完成后,再重新启动系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } }
/// <summary> /// 取第一块硬盘编号 /// </summary> /// <returns></returns> public static string[] GetHardDiskID() { var temp = new List <string>(); for (int i = 0; i < HardDriveCount; i++) { var t = AtapiDevice.GetHddInfo((byte)i); temp.Add(t.SerialNumber); } //using (var searcher = new ManagementObjectSearcher("Select * FROM Win32_PhysicalMedia")) //{ // var moList = searcher.Get(); // for (int i = 0; i < moList.Count; i++) // { // try // { // var t = AtapiDevice.GetHddInfo((byte)i); // temp.Add(t.SerialNumber); // } // catch (Exception) // { // continue; // } // } //} return(temp.ToArray()); }
/// <summary> /// 获取第一块硬盘的序列号 /// </summary> /// <returns></returns> public static string GetFirstHardDiskID() { try { return(AtapiDevice.GetHddInfo(0).SerialNumber); } catch (Exception) { return(string.Empty); } }
// Token: 0x060001D2 RID: 466 RVA: 0x000090F0 File Offset: 0x000072F0 public MainForm() { this.InitializeComponent(); string text; try { text = AtapiDevice.GetHddInfo(0).SerialNumber.Trim(); } catch (Exception) { Hardware hardware = new Hardware(); text = hardware.GetHardDiskID(); } setCode(text); }
// Token: 0x06000289 RID: 649 RVA: 0x00015A48 File Offset: 0x00013C48 public RegisterForm() { this.InitializeComponent(); string text; try { text = AtapiDevice.GetHddInfo(0).SerialNumber.Trim(); } catch (Exception) { Hardware hardware = new Hardware(); text = hardware.GetHardDiskID(); } this.hardwareInfoTB.Text = text; this.registerStringTB.Text = ""; }
private void btnReg_Click(object sender, System.EventArgs e) { string str_ss1, str_ss2, str_ss3, str_ss4, str_ss5; string str_sn1, str_sn2, str_sn3, str_sn4, str_sn5; if (txts5.Text.Trim().Length != 5) { MessageBox.Show("注册序列号不正确,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { str_sn5 = txts5.Text.Trim(); str_ss1 = txts5.Text.Trim().Substring(4, 1); } if (txts4.Text.Trim().Length != 5) { MessageBox.Show("注册序列号不正确,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { str_sn4 = txts4.Text.Trim(); str_ss2 = txts4.Text.Trim().Substring(3, 1); } if (txts3.Text.Trim().Length != 5) { MessageBox.Show("注册序列号不正确,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { str_sn3 = txts3.Text.Trim(); str_ss3 = txts3.Text.Trim().Substring(2, 1); } if (txts2.Text.Trim().Length != 5) { MessageBox.Show("注册序列号不正确,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { str_sn2 = txts2.Text.Trim(); str_ss4 = txts2.Text.Trim().Substring(1, 1); } if (txts1.Text.Trim().Length != 5) { MessageBox.Show("注册序列号不正确,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } else { str_sn1 = txts1.Text.Trim(); str_ss5 = txts1.Text.Trim().Substring(0, 1); } //读硬盘的序列号 string str_SerialNumber; string str_nb1, str_nb2, str_nb3, str_nb4, str_nb5; HardDiskInfo hdd = AtapiDevice.GetHddInfo(0); // 第一个硬盘 str_SerialNumber = hdd.SerialNumber.ToString(); //AtapiDevice.getHDDID().Trim();// str_nb1 = str_SerialNumber.Substring(0, 1); str_nb2 = str_SerialNumber.Substring(1, 1); str_nb3 = str_SerialNumber.Substring(2, 1); str_nb4 = str_SerialNumber.Substring(3, 1); str_nb5 = str_SerialNumber.Substring(4, 1); if (str_nb1 == str_ss1 && str_nb2 == str_ss2 && str_nb3 == str_ss3 && str_nb4 == str_ss4 && str_nb5 == str_ss5) { //加密 DESEncryptor dese1 = new DESEncryptor(); dese1.InputString = str_sn1 + "-" + str_sn2 + "-" + str_sn3 + "-" + str_sn4 + "-" + str_sn5; dese1.EncryptKey = "zhenghua0lhgynkm0"; dese1.DesEncrypt(); string mingWen = dese1.OutString; dese1 = null; //写注册表 string name = "ProductKey"; string tovalue = mingWen; string[] subkeyNames; bool _exist = false; if (tovalue != "") { RegistryKey hklm = Registry.LocalMachine; RegistryKey software = hklm.OpenSubKey("SOFTWARE", true); subkeyNames = software.GetSubKeyNames(); foreach (string keyName in subkeyNames) { if (keyName == "KMMWAMS") { RegistryKey aimdir = software.OpenSubKey("KMMWAMS", true); aimdir.SetValue(name, tovalue); _exist = true; } } if (!_exist) { RegistryKey aimdir = software.CreateSubKey("KMMWAMS"); aimdir.SetValue(name, tovalue); } MessageBox.Show("恭喜,您已成功注册,系统将自动退出,稍后请重新启动会员管理系统!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); Application.Exit(); } else { MessageBox.Show("注册失败,请稍后重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } } else { MessageBox.Show("注册序列号不正确,请检查!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } }
// Token: 0x060001CD RID: 461 RVA: 0x000088C0 File Offset: 0x00006AC0 private void LoginForm_Load(object sender, EventArgs e) { string text; try { text = AtapiDevice.GetHddInfo(0).SerialNumber.Trim(); } catch (ApplicationException) { Hardware hardware = new Hardware(); text = hardware.GetHardDiskID(); } if (text == "") { DialogResult dialogResult = WMMessageBox.Show(this, "无法读取硬盘信息!"); if (dialogResult == DialogResult.OK) { Application.Exit(); } return; } DbUtil dbUtil = new DbUtil(); DataRow dataRow = dbUtil.ExecuteRow("SELECT * FROM settings"); if (dataRow == null) { this.readRegisterInfofailed("无法读取系统配置!"); return; } uint num = ConvertUtils.ToUInt32(dataRow["totalRegTime"].ToString()); if (num == 0U) { RegisterForm registerForm = new RegisterForm(); registerForm.ShowDialog(); base.Visible = false; return; } DataTable dataTable = dbUtil.ExecuteQuery("SELECT * FROM histRgTable"); if (dataTable != null && dataTable.Rows != null && (long)dataTable.Rows.Count != (long)((ulong)num)) { DialogResult dialogResult2 = WMMessageBox.Show(this, "历史注册信息不符!"); if (dialogResult2 == DialogResult.OK) { Application.Exit(); } return; } dbUtil.AddParameter("code", text); DataRow dataRow2 = dbUtil.ExecuteRow("SELECT * FROM rgTable where code=@code"); ulong num2 = (dataRow2 != null) ? ConvertUtils.ToUInt64(dataRow2["ivd"].ToString()) : RegisterUtil.GetTimeStamp(); long num3 = (long)(num2 - RegisterUtil.GetTimeStamp()); if (num3 <= 2592000L) { if (num3 > 0L) { DialogResult dialogResult3 = WMMessageBox.Show(this, "软件即将过期,是否重新注册?", "卡表管理软件", MessageBoxButtons.OKCancel); if (dialogResult3 == DialogResult.OK) { RegisterForm registerForm2 = new RegisterForm(); registerForm2.ShowDialog(); base.Visible = false; } } else { DialogResult dialogResult4 = WMMessageBox.Show(this, "软件已经过期,是否重新注册?", "卡表管理软件", MessageBoxButtons.OKCancel); if (dialogResult4 == DialogResult.OK) { RegisterForm registerForm3 = new RegisterForm(); registerForm3.ShowDialog(); base.Visible = false; return; } Application.Exit(); return; } } ulong num4 = ConvertUtils.ToUInt64(dataRow2["d"].ToString()); if (num4 > RegisterUtil.GetTimeStamp()) { this.readRegisterInfofailed("请检查时间设置是否正确!"); return; } ulong num5 = ConvertUtils.ToUInt64(dataRow2["lud"].ToString()); if (num5 >= RegisterUtil.GetTimeStamp()) { this.readRegisterInfofailed("请检查时间设置是否正确!"); return; } string keyString = (dataRow2 == null) ? "" : dataRow2["key"].ToString(); if (!RegisterUtil.getRegisterResult(text, keyString)) { DialogResult dialogResult5 = WMMessageBox.Show(this, "注册号码不正确,需要重新注册?", "卡表管理软件", MessageBoxButtons.OKCancel); if (dialogResult5 == DialogResult.OK) { RegisterForm registerForm4 = new RegisterForm(); registerForm4.ShowDialog(); base.Visible = false; return; } Application.Exit(); } }
private static void UpdateEarlierDB() { string str7; string pValue = ""; bool node = ConfigHelper.GetNode("ftpUpAddress", ref pValue); string str2 = ""; bool flag2 = ConfigHelper.GetNode("ftpUser", ref str2); string ftpUserID = ConfigHelper.EncryptCode(str2, 1); string str4 = ""; bool flag3 = ConfigHelper.GetNode("ftpPwd", ref str4); string ftpPassword = ConfigHelper.EncryptCode(str4, 1); Ping ping = new Ping(); try { if (ping.Send("www.baidu.com").Status == IPStatus.Success) { goto Label_010B; } } catch (Exception exception) { ErrorLog.WriterLog("ping 百度 失败!" + exception.Message); LogHelper.LogError(exception); } string gateWay = GetGateWay(); if (string.IsNullOrWhiteSpace(gateWay)) { ErrorLog.WriterLog("没有获取到有效的网关!"); return; } if ((!node && !flag2) && !flag3) { ErrorLog.WriterLog("远程服务器地址不正确!"); return; } if (!NetworkInterface.GetIsNetworkAvailable()) { ErrorLog.WriterLog("无有效的网络连接!"); return; } try { if (ping.Send(gateWay).Status != IPStatus.Success) { ErrorLog.WriterLog("无法登录到远程服务器!"); return; } } catch (Exception exception2) { ErrorLog.WriterLog("登录到远程服务器错误!"); LogHelper.LogError(exception2); return; } Label_010B: str7 = Environment.CurrentDirectory + @"\SQlite\QCDB.db"; string str8 = str7.Substring(0, str7.LastIndexOf(@"\")); string str9 = AtapiDevice.GetHddInfo(0).SerialNumber.Trim(); if (!Directory.Exists(str8 + @"\BackUp")) { Directory.CreateDirectory(str8 + @"\BackUp"); } string str10 = ""; ConfigHelper.GetNode("orgCode", ref str10); string str11 = string.Format("{0}_{1}_{2}_qcdb.db", str10, str9, DateTime.Now.ToString("yyyyMMddHHmmss")); string destFileName = string.Format(str8 + @"\BackUp\{0}", str11); System.IO.File.Copy(str7, destFileName); if (System.IO.File.Exists(str7)) { try { int num = FtpOper.UploadFtp(str7, pValue, ftpUserID, ftpPassword, null, str11); GC.Collect(); ErrorLog.WriterLog("FtpOper.UploadFtp:" + str7 + " ftpAddr:" + pValue + " _fileName"); if (num == -2) { ErrorLog.WriterLog("网络不通,将无法完成数据同步!"); } else { Thread.Sleep(0x3e8); System.IO.File.Move(str7, str7 + ".bk"); ErrorLog.WriterLog("删除数据库!" + str7); } } catch (Exception exception3) { LogHelper.LogInfo(exception3); } } }