private void ChcekLicense() { string strdogmsg = Api.ReadDog(0, StartUpClass.handle); string strdogsmsg = Api.ReadDog(128, StartUpClass.handle); if ((strdogmsg == string.Empty) && (strdogsmsg == string.Empty)) { this.txt_MachineID.Text = m_termSoftReg.GetMNum(); this.txt_press.Text = m_termSoftReg.str_IssuingDate.ToShortDateString(); this.txt_mature.Text = m_termSoftReg.str_InitPermitDate.ToShortDateString(); Api.WriteDog(this.txt_MachineID.Text, 0, StartUpClass.handle); Thread.Sleep(2); strdogmsg = Api.ReadDog(0, StartUpClass.handle); DateTime dogDateTime = m_termSoftReg.Register(strdogmsg); timeState = new DateTime(dogDateTime.Year, dogDateTime.Month, dogDateTime.Day, 12, 0, 0); Thread.Sleep(2); int o3 = AESHelper.ConvertDateTimeInt(m_termSoftReg.str_IssuingDate); Api.WriteDog(o3.ToString(), 64, StartUpClass.handle); LicenseMsg.Save(AESHelper.EncryptStr(SoftReg.MachineID), @"armcc01_intr"); m_licenseMsg = new LicenseMsg(SoftReg.MachineID, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0), m_termSoftReg.str_IssuingDate, m_termSoftReg.str_InitPermitDate); b_IsUseTimeOver = false; } else { this.txt_MachineID.Text = strdogmsg; //ID string strIssuingDate = Api.ReadDog(64, StartUpClass.handle); _IssuingDate = AESHelper.GetTime(strIssuingDate); this.txt_press.Text = _IssuingDate.ToShortDateString(); //发行时间 string term0 = AESHelper.Decrypt(strdogmsg, "qwertyuiop"); string strend = term0.Substring(9, 10); if (strend.CompareTo("JJJ868JJJJ") == 0) { txt_mature.Text = "无限期"; groupBox5_ma.Enabled = false; b_IsUseTimeOver = false; return; } DateTime nowDateTime = DateTime.Now; DateTime dogDateTime = m_termSoftReg.Register(strdogmsg); DateTime machineDateTime = m_termSoftReg.Register(strdogsmsg); this.txt_mature.Text = dogDateTime.ToShortDateString(); //注册时间 DateTime dogDateTime12 = timeState = new DateTime(dogDateTime.Year, dogDateTime.Month, dogDateTime.Day, 12, 0, 0); if (DateTime.Compare(nowDateTime, machineDateTime) <= 0) { //系统时间错误,请联系厂家解决 lbl_msg.Text = "系统时间错误,请联系厂家解决:" + machineDateTime.ToString() + "/" + nowDateTime.ToString(); lbl_msg.BackColor = SystemColors.Control; lbl_msg.ForeColor = Color.Red; skinTabControl1.SelectedIndex = 7; } else { if (DateTime.Compare(nowDateTime, dogDateTime12) >= 0) { //注册到期 skinTabControl1.SelectedIndex = 7; lbl_msg.Text = "使用时间到期,请联系厂家"; lbl_msg.BackColor = SystemColors.Control; lbl_msg.ForeColor = Color.Blue; } else { b_IsUseTimeOver = false; m_licenseMsg = new LicenseMsg(SoftReg.GetDogNumber(StartUpClass.handle), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0), _IssuingDate, dogDateTime); int days = (dogDateTime12 - nowDateTime).Days; if (days <= 5) { // pnl_SoftwaretrialInfo.Visible = true; // lbl_SoftwaretrialInfo.Visible = true; if (days < 0) { MessageBox.Show("软件使用已到期,请注册!!!!!"); stateData = true; //注册到期 skinTabControl1.SelectedIndex = 7; lbl_msg.Text = "使用时间到期,请联系厂家"; lbl_msg.BackColor = SystemColors.Control; lbl_msg.ForeColor = Color.Blue; b_IsUseTimeOver = true; } else { // tabControl1.SelectedIndex = 0; // MessageBox.Show("软件使用日期剩余:" + days + "天"); stateData = true; } } else { // tabControl1.SelectedIndex = 0; } } } } if (Api.R1_Close(StartUpClass.handle) != 0) //关闭Rockey1 { throw new Exception("关闭加密狗......失败"); } }