views:

444

answers:

1

Hi,

I got below mentioned code for adding my application to Windows Firewall Exception list. I wanted to know if this will also work for other firewalls eg: Antivirus firewalls etc. If not then please suggest a solution. Note: My application is running with Admin rights but my users are not able to understand firewall settings of quickheal etc. I use Delphi 2007 (Win32).

This is the first time I am using this forum. Please excuse+correct any mistakes.

Regards Allan Fernandes

procedure AddApplicationToFirewall(EntryName:string;ApplicationPathAndExe:string);
var
  fwMgr,app:OleVariant;
  profile:OleVariant;
begin
  fwMgr := CreateOLEObject('HNetCfg.FwMgr');
  profile := fwMgr.LocalPolicy.CurrentProfile;
  app := CreateOLEObject('HNetCfg.FwAuthorizedApplication');
  app.ProcessImageFileName := ApplicationPathAndExe;
  app.Name := EntryName;
  app.Scope := NET_FW_SCOPE_ALL;
  app.IpVersion := NET_FW_IP_VERSION_ANY;
  app.Enabled :=true;
  profile.AuthorizedApplications.Add(app);
end;
+3  A: 

@Allan, your code only works for the windows firewall or for Firewalls wich uses the windows firewall exceptions list.

unfortunately there is no standard way of adding exceptions to third-party firewalls, since most of these use their own methods to handle exceptions and access rules.

RRUZ
Allan, if you write such a "firewall rule library" for Delphi, it might be really handy for people who want to install software that can help users configure their firewalls.
Warren P
JWSCL supports Windows Firewallhttp://jwscldoc.delphi-jedi.net/TJwsclFirewall.html
ChristianWimmer