title: How can I detect if a firewall product is enabled?
body: <p>How can I detect (from a Windows Forms application written in C#) if a firewall product is enabled?</p>
  
  <p>Here is my code and i am getting error on <strong>INetFwMgr that type or namespace could not found</strong></p>
  
  <pre><code>namespace WindowsFormsApplication1
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
  
          private const string CLSID_FIREWALL_MANAGER = "{304CE942-6E39-40D8-943A-B913C40C9CD4}"; 
  
         INetFwMgr manager = GetFireWallManager();
         bool isFirewallEnabled = manager.LocalPolicy.CurrentProfile.FirewallEnabled;
  
  
  
         private static INetFwMgr GetFireWallManager()
         {
             Type objectType = Type.GetTypeFromCLSID(new Guid(CLSID_FIREWALL_MANAGER));
             return Activator.CreateInstance(objectType) as INetFwMgr;
         }
          private void button1_Click(object sender, EventArgs e)
          {
  
  
  
              if (isFirewallEnabled == false)
             {
                  MessageBox.Show("Firewall is not enabled.");
             }
             else
             {
                  MessageBox.Show("Firewall is enabled.");
             }
  
          }
      }
  }
  </code></pre>