Delphi 7 Windows Vista/7 防火墙例外网络位置
procedure AddExceptionToFirewall (Caption: String; Executable: String);
var
FirewallMsg: OleVariant;
Application: OleVariant;
CurrentProfile: OleVariant;
begin
FirewallMsg:= CreateOLEObject ('HNetCfg.FwMgr');
CurrentProfile:= FirewallMsg.LocalPolicy.CurrentProfile;
Application:= CreateOLEObject ('HNetCfg.FwAuthorizedApplication');
Application.ProcessImageFileName:= Executable;
Application.Name:= Caption;
Application.Scope:= FW_SCOPE_ALL;
Application.IpVersion:= FW_IP_VERSION_ANY;
Application.Enabled:= True;
CurrentProfile.AuthorizedApplications.Add (Application);
end;
问题是,在 Windows 7 上,它仅将例外添加为 Public 而不是为私有,如您在此处以 RED 圈出的那样
设置为公共时只是,我的程序在通过 FTP 连接访问我的主机时出现问题,从而导致我的程序无用。 此问题仅针对 Windows Vista/7;在 XP 上,当前配置运行良好。
如果您有任何线索或有用的指示,请分享。
I have this chunk of code which I found and implemented according to http://www.activexperts.com/activmonitor/windowsmanagement/scripts/networking/windowsfirewall/
procedure AddExceptionToFirewall (Caption: String; Executable: String);
var
FirewallMsg: OleVariant;
Application: OleVariant;
CurrentProfile: OleVariant;
begin
FirewallMsg:= CreateOLEObject ('HNetCfg.FwMgr');
CurrentProfile:= FirewallMsg.LocalPolicy.CurrentProfile;
Application:= CreateOLEObject ('HNetCfg.FwAuthorizedApplication');
Application.ProcessImageFileName:= Executable;
Application.Name:= Caption;
Application.Scope:= FW_SCOPE_ALL;
Application.IpVersion:= FW_IP_VERSION_ANY;
Application.Enabled:= True;
CurrentProfile.AuthorizedApplications.Add (Application);
end;
The thing is, on Windows 7, it adds the exception only as Public and not as Private as you can see circled in RED in here
When set to Public only, my program has problems accessing my host via an FTP connection, thus rendering my program useless.
This problem is particular only for Windows Vista/7; on XP, the current configuration works fine.
Please if you have any clue or helpful pointers, share them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 Windows Vista 开始,您必须使用 INetFwPolicy2 和 INetFwRule 接口获取访问权限新的防火墙功能。
尝试此示例,在公共和私人配置文件中添加新规则。
Starting with windows Vista you must use the INetFwPolicy2 and INetFwRule interfaces to gain access to the new firewall features.
Try this sample which add a new rule in the Public and Private profile.