Add to Firewall Exception list

帅比萌擦擦* 提交于 2019-12-18 11:15:11

问题


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;

回答1:


@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.



来源:https://stackoverflow.com/questions/2384718/add-to-firewall-exception-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!