uses ComObj;
implementation
Const NET_FW_IP_PROTOCOL_UDP = 17;
Const NET_FW_IP_PROTOCOL_TCP = 6;
Const NET_FW_SCOPE_ALL = 0;
Const NET_FW_SCOPE_LOCAL_SUBNET = 1;
procedure TForm1.Button1Click(Sender: TObject);
var
FwMgr,Profile,port: variant;
begin
//Create the firewall manager object
FwMgr:= CreateOLEObject('HNetCfg.FwMgr');
//Get the current profile for the local firewall policy
Profile:= FwMgr.LocalPolicy.CurrentProfile;
//Dim port
port:= CreateOLEObject('HNetCfg.FWOpenPort');
port.Name:= 'MySql4';
port.Protocol:= NET_FW_IP_PROTOCOL_TCP;
port.port:= 3306;
port.Scope:= NET_FW_SCOPE_ALL;
port.Enabled:= TRUE;
profile.GloballyOpenPorts.Add(port);
end;
4758

被折叠的 条评论
为什么被折叠?



