RemoveFirewallAccess() public static method

Removes the firewall access granted to the specified ports.
public static RemoveFirewallAccess ( ) : void
return void
Ejemplo n.º 1
0
        private void RemoveBTN_Click(object sender, EventArgs e)
        {
            try
            {
                List <int>          portsToRemove = new List <int>();
                List <ListViewItem> itemsToRemove = new List <ListViewItem>();

                for (int ii = 0; ii < PortsLV.SelectedItems.Count; ii++)
                {
                    int?port = PortsLV.SelectedItems[ii].Tag as int?;

                    if (port != null)
                    {
                        portsToRemove.Add(port.Value);
                        itemsToRemove.Add(PortsLV.SelectedItems[ii]);
                    }
                }

                if (portsToRemove.Count > 0)
                {
                    ConfigUtils.RemoveFirewallAccess(portsToRemove.ToArray());
                    UpdatePorts();
                }
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, System.Reflection.MethodBase.GetCurrentMethod(), exception);
            }
        }
Ejemplo n.º 2
0
        private void ApplicationAccessGrantedCK_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                if (m_application != null)
                {
                    bool accessible = ConfigUtils.CheckFirewallAccess(m_application.ExecutablePath, null);

                    if (ApplicationAccessGrantedCK.Checked)
                    {
                        if (!accessible)
                        {
                            ConfigUtils.SetFirewallAccess(m_application.ExecutablePath, null);
                        }
                    }
                    else
                    {
                        if (accessible)
                        {
                            ConfigUtils.RemoveFirewallAccess(m_application.ExecutablePath, null);
                        }
                    }
                }

                PortsLV.Enabled   = ApplicationAccessGrantedCK.Checked;
                AddBTN.Enabled    = PortsLV.Enabled;
                RemoveBTN.Enabled = PortsLV.Enabled;
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, System.Reflection.MethodBase.GetCurrentMethod(), exception);
            }
        }
Ejemplo n.º 3
0
        void Port_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                CheckBox box = (CheckBox)sender;

                if (box.Checked)
                {
                    ConfigUtils.SetFirewallAccess(m_application.ExecutablePath, (int)box.Tag);
                }
                else
                {
                    ConfigUtils.RemoveFirewallAccess((int)box.Tag);
                }

                UpdatePorts();
            }
            catch (Exception exception)
            {
                GuiUtils.HandleException(this.Text, System.Reflection.MethodBase.GetCurrentMethod(), exception);
            }
        }