Exemplo n.º 1
0
        private void ActionButton_Click(object sender, EventArgs e)
        {
            string errMsg = string.Empty;

            if (DriverInstaller.DriverAlreadyExits(ref errMsg))
            {
                string errorMsg = string.Empty;
                if (DriverInstaller.DeleteDriver(ref errorMsg))
                {
                    MessageBox.Show(
                        "Netfilter successfully uninstalled!", string.Empty,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(
                        string.Format("Couldn't uninstall Netfilter..\r\nError: {0}", errorMsg),
                        "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                string errorMsg = string.Empty;
                DriverInstaller.DriverType driverType = (wfpDriverRadioButton.Checked) ?
                                                        DriverInstaller.DriverType.WFP : DriverInstaller.DriverType.TDI;

                if (DriverInstaller.InstallDriver(ref errorMsg, driverType))
                {
                    MessageBox.Show(
                        "Netfilter successfully installed!", string.Empty,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(
                        string.Format("Couldn't install Netfilter..\r\nError: {0}", errorMsg),
                        "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (errMsg != string.Empty)
            {
                MessageBox.Show(
                    string.Format("Couldn't install Netfilter..\r\nError: {0}", errMsg),
                    "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Close();
        }
Exemplo n.º 2
0
        private void ActionButton_Click(object sender, EventArgs e)
        {
            if (DriverInstaller.Installed())
            {
                string errorMsg = string.Empty;
                if (DriverInstaller.DeleteDriver(ref errorMsg))
                {
                    DialogResult dialogResult = MessageBox.Show(
                        "Netfilter successfully uninstalled!\n" +
                        "For complete uninstallation require reboot.\nReboot now?", "",
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dialogResult == DialogResult.Yes)
                    {
                        Process.Start("shutdown", "/r /t 10");
                    }
                }
                else
                {
                    MessageBox.Show(
                        string.Format("Couldn't uninstall Netfilter..\r\nError: {0}", errorMsg),
                        "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                string errorMsg = string.Empty;
                DriverInstaller.DriverType driverType = (wfpDriverRadioButton.Checked) ?
                                                        DriverInstaller.DriverType.WFP : DriverInstaller.DriverType.TDI;

                if (DriverInstaller.InstallDriver(ref errorMsg, driverType))
                {
                    MessageBox.Show(
                        "Netfilter successfully installed!", string.Empty,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(
                        string.Format("Couldn't install Netfilter..\r\nError: {0}", errorMsg),
                        "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            Close();
        }