Esempio n. 1
0
        // 定时查询是否激活 防止破解
        private void TimerQueryActivation(object sender, EventArgs e)
        {
            String activationCode = INIHelper.Read("Info", "ActivationCode", "", BaseConfig.CONFIG_PATH);

            if (string.IsNullOrEmpty(activationCode) || string.IsNullOrWhiteSpace(activationCode))
            {
                Application.Current.Shutdown();
            }
            else
            {
                ValiCode(_globalParam.m_Handle, activationCode);
                // 验证失败直接关闭应用
                if (_valiCode >= 3)
                {
                    YouyiSdk.M_Close(_globalParam.m_Handle);
                    if (!showMessageBox)
                    {
                        showMessageBox = true;
                        MessageBox.Show("卡密不正确,请重新激活!");
                    }
                    INIHelper.DeleteKey("Info", "ActivationCode", BaseConfig.CONFIG_PATH);
                    DelegeteShutDownApp();
                }
            }
        }
Esempio n. 2
0
        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // 关闭芯片
            YouyiSdk.M_Close(_globalParam.m_Handle);
            // 删除武器识别图片
            if (!BaseConfig.DEBUG)
            {
                if (System.IO.File.Exists(_globalParam.IdenWeaponImgName))
                {
                    System.IO.File.Delete(_globalParam.IdenWeaponImgName);
                }
            }

            CreateDeskTopLnk();

            Application.Current.Shutdown();
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();
            this._mainWindowViewModel = MainWindowViewModel.GetMainWindowViewModel();
            base.DataContext          = _mainWindowViewModel;
            _globalParam            = GlobalParam.GetGlobalParam();
            _globalParam.MainWindow = this;
            this.Closing           += MainWindow_Closing;
            //QueryProcess();


            // 查询是否激活
            String activationCode = INIHelper.Read("Info", "ActivationCode", "", BaseConfig.CONFIG_PATH);

            if (string.IsNullOrEmpty(activationCode) || string.IsNullOrWhiteSpace(activationCode))
            {
                // 填写激活码
                ActivationWindow activation = new ActivationWindow();
                activation.ShowDialog();
            }
            // 进入首次验证
            TimerQueryActivation(null, null);
            if (_valiCode == 1)
            {
                YouyiSdk.M_Close(_globalParam.m_Handle);
                if (!showMessageBox)
                {
                    showMessageBox = true;
                    MessageBox.Show("卡密不正确,请重新激活!");
                }
                INIHelper.DeleteKey("Info", "ActivationCode", BaseConfig.CONFIG_PATH);
                DelegeteShutDownApp();
            }
            // 定时查询激活
            timer           = new Timer();
            timer.Elapsed  += new ElapsedEventHandler(TimerQueryActivation);
            timer.Interval  = 1000 * 60 * 3;
            timer.Enabled   = true;
            timer.AutoReset = true;
        }