Esempio n. 1
0
 // 卸载驱动 按钮按下
 private void Uninstall_Button_Click(object sender, EventArgs e)
 {
     if (FKWindowsSecurity.IsAdmin())
     {
         UninstallDriver();
     }
     else
     {
         FKWindowsSecurity.RestartElevated(ENUMStartupActions.UninstallDriver.ToString());
     }
 }
Esempio n. 2
0
        // 检查当前驱动
        private void CheckCurrentDriverStates()
        {
            bool bInstallDriver = false;

            System.Diagnostics.FileVersionInfo myDriverVersion;
            // 检查驱动兼容性
            if (FKDriverManagement.IsDriverInstalled(out myDriverVersion))
            {
                string  thatVersion = string.Format("{0}.{1}", myDriverVersion.FileMajorPart, myDriverVersion.FileMinorPart);
                Version assVersion  = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                string  thisVersion = string.Format("{0}.{1}", assVersion.Major, assVersion.Minor);
                if (thatVersion != thisVersion)
                {
                    if (MessageBox.Show(
                            string.Format("本机 FK USB 驱动版本 ({0}) 不符合当前驱动版本 ({1}). 你是否要将其更改为 {1} ?",
                                          thatVersion,
                                          thisVersion),
                            "驱动版本不匹配",
                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        bInstallDriver = true;
                    }
                }
            }
            else
            {
                if (MessageBox.Show(
                        "FK USB 驱动尚未安装. 你是否要立刻安装 ?",
                        "FK USB 驱动检查",
                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    bInstallDriver = true;
                }
            }

            // 看看是否需要安装驱动
            if (bInstallDriver)
            {
                if (FKWindowsSecurity.IsAdmin())
                {
                    InstallDriver();
                }
                else
                {
                    FKWindowsSecurity.RestartElevated(ENUMStartupActions.InstallDriver.ToString());
                }
            }
        }
Esempio n. 3
0
        public MainForm()
        {
            InitializeComponent();

            // 核心对象初始化
            m_Native    = new FKNative();
            m_DevManage = new FKDeviceManagement();
            m_PrevTrace = new FKFilterTrace();

            // 其他控件初始化
            if (!FKWindowsSecurity.IsAdmin())
            {
                this.Text += " (非管理员)";
                FKWindowsSecurity.AddShieldToButton(Reinstall_Button);
                FKWindowsSecurity.AddShieldToButton(Uninstall_Button);
            }
            else
            {
                this.Text += " (管理员)";
            }

            cbMaxTraces.SelectedIndex = 0;
        }