使用UPnP转发端口-关闭端口 [英] Port Forward using UPnP - close port
本文介绍了使用UPnP转发端口-关闭端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Port Forwarding by Using "HNetCfg.NATUPnP" Ole Object Failed中的代码进行端口转发,工作正常,只是在应用程序终止时无法关闭端口。
AddUPnPEntry(1234, 'Hello3', '192.168.1.34');
尽管我重启了我的电脑,但1234端口仍然打开,我在canyouseame.org上测试了它。
那么,我如何关闭该端口?
编辑:已解决,我只需要重新启动(关闭并打开)我的路由器以再次关闭端口。
推荐答案
AddUPnPEntry()
使用IStaticPortMappingCollection.Add()
方法。有关联的IStaticPortMappingCollection.Remove()
方法,例如:
Procedure RemoveUPnPEntry(Port: Integer);
Var
Nat: Variant;
Ports: Variant;
Begin
try
Nat := CreateOleObject('HNetCfg.NATUPnP');
Ports := Nat.StaticPortMappingCollection;
Ports.Remove(Port, 'TCP');
except
ShowMessage('An Error occured with removing UPnP Ports. ' +
'Please check to see if your router supports UPnP and ' +
'has it enabled or disable UPnP.');
end;
End;
RemoveUPnPEntry(1234);
这篇关于使用UPnP转发端口-关闭端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文