Jump to content
  • Advertisement
Sign in to follow this  
wind_addict

Windows XP firewall retrieving its policy in C++

This topic is 3714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
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);


Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!