0
我試圖阻止或使用80 TCP端口,此代碼解鎖不工作的端口:使用NetFwTypeLib以阻止或允許使用防火牆設置在Windows XP
const string guidFWPolicy2 = "{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD}";
const string guidRWRule = "{2C5BC43E-3369-4C33-AB0C-BE9469677AF4}";
Type typeFWPolicy2 = Type.GetTypeFromCLSID(new Guid(guidFWPolicy2));
Type typeFWRule = Type.GetTypeFromCLSID(new Guid(guidRWRule));
INetFwPolicy2 fwPolicy2 =(INetFwPolicy2)Activator.CreateInstance(typeFWPolicy2);
INetFwRule newRule = (INetFwRule)Activator.CreateInstance(typeFWRule);
newRule.Name = "MabuAsTcpLocker_OutBound_Rule";
newRule.Description = "Block outbound traffic over TCP port 80";
newRule.Protocol = (int)NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP;
newRule.RemotePorts = "80";
newRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_OUT;
newRule.Enabled = true;
newRule.Profiles = fwPolicy2.CurrentProfileTypes;
newRule.Action = NET_FW_ACTION_.NET_FW_ACTION_BLOCK;
fwPolicy2.Rules.Add(newRule);
此代碼的工作就好上了Windows 7但在Windows XP上無法使用。在我的項目中,我只引用了NetFwTypeLib COM庫。 例外情況說,它無法找到並立即使用{E2B3C97F-6AE1-41AC-817A-F6F92166D7DD} Guid類。 請你幫助我嗎?