Win Xp firewall detection

This is a discussion on Win Xp firewall detection within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, I am trying to retrieve the current state of the Windows XP firewall in my program. I can ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    6

    Win Xp firewall detection

    Hi there, I am trying to retrieve the current state of the Windows XP firewall in my program. I can do it fine for the local firewall settings, however I don't know how to retrieve it when the PC is in a domain with a GPO setting for it.

    Here is a snippet of my code: I can determine when the firewall profile is of type NET_FW_PROFILE_DOMAIN, but how do I retrieve it? in MSDN I can only see a method to retrieve the local one.

    Code:
    HRESULT CFirewall::WindowsFirewallInitialize(OUT INetFwProfile **fwProfile)
     *fwProfile = NULL;
      NET_FW_PROFILE_TYPE fwPType;
    
      // Create an instance of the firewall settings manager.
      hr = CoCreateInstance(__uuidof(NetFwMgr), NULL, CLSCTX_INPROC_SERVER, __uuidof(INetFwMgr), (void **)&fwMgr);
      if(FAILED(hr)) 
        ShowError("CoCreate Instance failed.", hr);
    
      hr = fwMgr->get_CurrentProfileType(&fwPType);
      //if(fwPType == NET_FW_PROFILE_DOMAIN) //domain type get its settings
    
      // Retrieve the current firewall policy.   Local or Domain
      hr = fwMgr->get_LocalPolicy(&fwPolicy);  //this will retrieve the local policy only, how do I get the Domain based profile instead?
      if(FAILED(hr))
        ShowError("Get local policy failed.", hr);
    
      // Retrieve the firewall profile currently in effect.
      hr = fwPolicy->GetProfileByType(fwPType, fwProfile);
      if(FAILED(hr))
        ShowError("Get current profile failed.", hr);

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    >> //this will retrieve the local policy only, how do I get the Domain based profile instead?
    The INetFwProfile instance returned by fwPolicy->GetProfileByType() - isn't its Type property also NET_FW_PROFILE_DOMAIN? If so, then you've got your domain-profile-type instance.

    Quote Originally Posted by MSDN
    Instances of [INetFwPolicy] are retrieved through the LocalPolicy property of the INetFwMgr interface.
    That looks like the only place you can get a INetFwPolicy instance. It doesn't look like INetFwPolicy needs to have multiple instances, since a single instance can get you any profile type.

    What is intersting however, is that there's a documented NET_FW_POLICY_TYPE enum but there's no method or property tha uses that type....

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 05-07-2009, 11:31 AM
  2. help with this
    By tyrantil in forum C Programming
    Replies: 18
    Last Post: 01-30-2005, 03:53 PM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  4. Dual Booting Win XP & Win 98
    By netboy in forum Tech Board
    Replies: 2
    Last Post: 08-18-2003, 02:29 AM
  5. Win XP dial-up setup
    By C-Dumbie in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-15-2002, 12:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21