public bool Start(IntPtr handle, bool bWrBd) { DEV_BROADCAST_DEVICEINTERFACE dbf = new DEV_BROADCAST_DEVICEINTERFACE(); dbf.dbcc_size = Marshal.SizeOf(dbf); dbf.dbcc_devicetype = Common.DBT_DEVTYP_DEVICEINTERFACE; dbf.dbcc_reserved = 0; IntPtr hDevNotify1 = Common.RegisterDeviceNotification(handle, dbf, Common.DEVICE_NOTIFY_WINDOW_HANDLE | Common.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); int lt = 0; if (bWrBd) { BYHXSoftLock.CheckDongle_WrBd(); } else { BYHXSoftLock.CheckDongle(); } #if ADD_HARDKEY BYHX_SL_RetValue ret = BYHXSoftLock.CheckValidDate(ref lt); switch (ret) { case BYHX_SL_RetValue.EXPIRED: m_bOutdated = true; MessageBox.Show(ResString.GetResString("EncryptDog_Expired"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error); break; case BYHX_SL_RetValue.ILLEGALDOG: MessageBox.Show(ResString.GetResString("EncryptDog_Illegal"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); case BYHX_SL_RetValue.NOFOUNDDOG: MessageBox.Show(ResString.GetResString("EncryptDog_NoFound"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); case BYHX_SL_RetValue.WILLEXPIREDWORNING_100: MessageBox.Show(ResString.GetResString("EncryptDog_Warning"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Warning); tCheckDog.Interval = (lt - 1) * 60 * 1000 + 1; tCheckDog.Tick += new EventHandler(tCheckDog_Tick); tCheckDog.Start(); break; default: break; } if (lt > 60 * 100 && lt - 100 * 60 <= int.MaxValue / 1000 / 60) { tCloseTimer.Interval = (lt - 100 * 60) * 60 * 1000; tCloseTimer.Tick += new EventHandler(tCloseTimer_Tick); tCloseTimer.Start(); } #endif return(true); }
public bool LoadAndCheckDongleKey() { BYHXSoftLock.CheckDongle(); #if ADD_HARDKEY int lt = 0; BYHX_SL_RetValue ret = BYHXSoftLock.CheckValidDate(ref lt); m_bOutdated = false; switch (ret) { case BYHX_SL_RetValue.EXPIRED: m_bOutdated = true; break; case BYHX_SL_RetValue.ILLEGALDOG: case BYHX_SL_RetValue.NOFOUNDDOG: return(false); case BYHX_SL_RetValue.WILLEXPIREDWORNING_100: tCheckDog.Interval = (lt - 1) * 60 * 1000 + 1; tCheckDog.Tick += new EventHandler(tCheckDog_Tick); tCheckDog.Start(); break; default: break; } if (lt > 100 * 60 && lt - 100 * 60 <= int.MaxValue / 1000 / 60) { tCloseTimer.Interval = (lt - 100 * 60) * 60 * 1000; tCloseTimer.Tick += new EventHandler(tCloseTimer_Tick); tCloseTimer.Start(); } if (this.LoadAndCheckDongleKeyFinished != null) { this.LoadAndCheckDongleKeyFinished(null, new EventArgs()); } #endif return(true); }