示例#1
0
文件: MainForm.cs 项目: ywscr/busdog
 private bool ProcessCommandLine()
 {
     foreach (string arg in Environment.GetCommandLineArgs())
     {
         if (arg == StartupActions.InstallDriver.ToString())
         {
             if (VistaSecurity.IsAdmin())
             {
                 InstallDriver();
             }
             else
             {
                 MessageBox.Show("Could not install driver as user is not an Admin",
                                 "Startup Action Install Driver failed");
             }
             return(true);
         }
         else if (arg == StartupActions.UninstallDriver.ToString())
         {
             if (VistaSecurity.IsAdmin())
             {
                 UninstallDriver();
             }
             else
             {
                 MessageBox.Show("Could not uninstall driver as user is not an Admin",
                                 "Startup Action Uninstall Driver failed");
             }
             return(true);
         }
     }
     return(false);
 }
示例#2
0
文件: MainForm.cs 项目: ywscr/busdog
 private void btnUninstall_Click(object sender, EventArgs e)
 {
     if (VistaSecurity.IsAdmin())
     {
         UninstallDriver();
     }
     else
     {
         VistaSecurity.RestartElevated(StartupActions.UninstallDriver.ToString());
     }
 }
示例#3
0
文件: MainForm.cs 项目: ywscr/busdog
        private void CheckDriverInstallation()
        {
            bool installDriver = false;

            System.Diagnostics.FileVersionInfo busdogDriverVersion;
            // show driver incompatablities
            if (DriverManagement.IsDriverInstalled(out busdogDriverVersion))
            {
                string thatVersion = string.Format("{0}.{1}",
                                                   busdogDriverVersion.FileMajorPart,
                                                   busdogDriverVersion.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("BusDog Filter Driver version ({0}) does not match the GUI version ({1}). Would you like to install BusDog Filter Driver version {1} now?",
                                          thatVersion,
                                          thisVersion),
                            "Driver Version Mismatch",
                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        installDriver = true;
                    }
                }
            }
            else
            {
                if (MessageBox.Show(
                        "BusDog Filter Driver is not installed. Do you want to install it now?",
                        "Driver Not Installed",
                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    installDriver = true;
                }
            }
            // install driver if one of the complicated if descision trees above set 'installDriver'
            if (installDriver)
            {
                if (VistaSecurity.IsAdmin())
                {
                    InstallDriver();
                }
                else
                {
                    VistaSecurity.RestartElevated(StartupActions.InstallDriver.ToString());
                }
            }
        }
示例#4
0
文件: MainForm.cs 项目: ywscr/busdog
        public MainForm()
        {
            InitializeComponent();

            if (!VistaSecurity.IsAdmin())
            {
                VistaSecurity.AddShieldToButton(btnReinstall);
                VistaSecurity.AddShieldToButton(btnUninstall);
            }
            else
            {
                this.Text += " (Elevated)";
            }

            cbMaxTraces.SelectedIndex = 0;
        }