1 // Utility functions for Inno Setup 2 // used to add/remove programs from the windows firewall rules 3 // Code originally from http://news.jrsoftware.org/news/innosetup/msg43799.html 4 5 const 6 NET_FW_SCOPE_ALL = 0; 7 NET_FW_IP_VERSION_ANY = 2; 8 9 Procedure SetFirewallException(AppName, FileName : string); 10 var 11 FirewallObject: Variant; 12 FirewallManager: Variant; 13 FirewallProfile: Variant; 14 begin 15 try 16 FirewallObject := CreateOleObject('HNetCfg.FwAuthorizedApplication'); 17 FirewallObject.ProcessImageFileName := FileName; 18 FirewallObject.Name := AppName; 19 FirewallObject.Scope := NET_FW_SCOPE_ALL; 20 FirewallObject.IpVersion := NET_FW_IP_VERSION_ANY; 21 FirewallObject.Enabled := True; 22 FirewallManager := CreateOleObject('HNetCfg.FwMgr'); 23 FirewallProfile := FirewallManager.LocalPolicy.CurrentProfile; 24 FirewallProfile.AuthorizedApplications.Add(FirewallObject); 25 except 26 end; 27 end; 28 29 Procedure RemoveFirewallException(FileName : string); 30 var 31 FirewallManager: Variant; 32 FirewallProfile: Variant; 33 begin 34 try 35 FirewallManager := CreateOleObject('HNetCfg.FwMgr'); 36 FirewallProfile := FirewallManager.LocalPolicy.CurrentProfile; 37 FireWallProfile.AuthorizedApplications.Remove(FileName); 38 except 39 end; 40 end;