i7mad
asked on
Delphi and Windows Firewall Exceptions list
Hello,
How to add my Application Executable to Wndows Firewall Exception list automaticly, so that when my application runs on the machine for the first time it will add itself automaticly to windows firewall exception list without asking the user.
Windows Automaticly blocks any application trying to use the Internet/LAN connections, and asks the user to Unblock ot Keep Blocking the application from accesing the connection.
Some Users doesn't understand the message and click on KEPP BLOCKING, so that my application will not do its job.
How to add my Application Executable to Wndows Firewall Exception list automaticly, so that when my application runs on the machine for the first time it will add itself automaticly to windows firewall exception list without asking the user.
Windows Automaticly blocks any application trying to use the Internet/LAN connections, and asks the user to Unblock ot Keep Blocking the application from accesing the connection.
Some Users doesn't understand the message and click on KEPP BLOCKING, so that my application will not do its job.
ASKER
I think it is easier than using Outside laibraries.
Some API functions should solve the story.
Some API functions should solve the story.
ASKER
libraries
sorry typo
sorry typo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found this and it's worked :
uses ActiveX, ComObj;
const
NET_FW_PROFILE_DOMAIN = 0;
NET_FW_PROFILE_STANDARD = 1;
NET_FW_IP_VERSION_ANY = 2;
NET_FW_IP_PROTOCOL_UDP = 17;
NET_FW_IP_PROTOCOL_TCP = 6;
NET_FW_SCOPE_ALL = 0;
NET_FW_SCOPE_LOCAL_SUBNET = 1;
procedure AddPortToFirewall(EntryName:string;PortNumber:Cardinal);
var
fwMgr,port:OleVariant;
profile:OleVariant;
begin
fwMgr := CreateOLEObject('HNetCfg.FwMgr');
profile := fwMgr.LocalPolicy.CurrentProfile;
port := CreateOLEObject('HNetCfg.FWOpenPort');
port.Name := EntryName;
port.Protocol := NET_FW_IP_PROTOCOL_TCP;
port.Port := PortNumber;
port.Scope := NET_FW_SCOPE_ALL;
port.Enabled := true;
profile.GloballyOpenPorts.Add(port);
end;
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;
See http://blog.delphi-jedi.net/security-library/ and http://jwscldoc.delphi-jedi.net/index.html?frmname=topic&frmfile=JwsclFirewall_pas.html
I think you can use procedure AddToWinFirewall(Applicati