Click here to Skip to main content
15,899,549 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
This is my vb script that removes a firewall rule that allows an application through the Windows firewall.

VB
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colApplications = objPolicy.AuthorizedApplications

errReturn = colApplications.Remove("c:\windows\system32\freecell.exe")



I want to know how to implement the equivalent with vc++(msdev) code.

I don't know to instantiate a COM object with c++

I know i want to use COM..

pls help seniors
Posted
Updated 17-Oct-11 17:28pm
v2
Comments
Sergey Alexandrovich Kryukov 17-Oct-11 11:42am    
Not a question. I see what you want, what's your problem?
--SA
[no name] 17-Oct-11 23:26pm    
He is apparently showing some VB script utilizing the firewall manager for removing an application firewall rule and asking how to implement the same thing under COM with the C++ language. (I have updated the original question to make it more clear)

1 solution

Hi,

Have a look at the MSDN article: Exercising the Firewall using C++[^]

The VB script sample you posted appears to be removing a firewall application rule. If you wanted to do this under COM with C++ you would need modify the line in the sample function WindowsFirewallAddApp:

C++
hr = fwApps->Add(fwApp);


And change it to:

C++
hr = fwApps->Remove(fwApp);


Don't forget to rename the function to something like WindowsFirewallRemoveApp or it will drive a future project maintainer crazy. :)

Best Wishes,
-David Delaune
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900