我试图从像这样的程序调用一个函数
//////////////////////////////////////////
// Add Firewall Exception //
/////////////////////////////////////////
procedure CallAddPortException(Value: string);
begin
SetFirewallPortException('MysqlPort'; NET_FW_PROTOCOL_TCP, 3311); '<= Error line
end;
//////////////////////////////////////////
// Add Firewall Exception //
/////////////////////////////////////////
procedure SetFirewallPortException(AppName: string; Protocol, Port: integer);
var
FirewallObject: Variant;
FirewallManager: Variant;
FirewallProfile: Variant;
begin
try
FirewallObject := CreateOleObject('HNetCfg.FwOpenPort');
FirewallObject.Name := AppName;
FirewallObject.Scope := NET_FW_SCOPE_ALL;
FirewallObject.IpVersion := NET_FW_IP_VERSION_ANY;
FirewallObject.Protocol := Protocol;
FirewallObject.Port := Port;
FirewallObject.Enabled := True;
FirewallManager := CreateOleObject('HNetCfg.FwMgr');
FirewallProfile := FirewallManager.LocalPolicy.CurrentProfile;
FirewallProfile.GloballyOpenPorts.Add(FirewallObject);
except
end;
end;
但我似乎无法让它发挥作用。我收到以下错误
Unknown Identifier 'SetFirewallPortException'