我使用以下代码查找转发的端口..。
Nat := CreateOleObject('HNetCfg.NATUPnP');
Ports := Nat.StaticPortMappingCollection;
if not VarIsClear ( Ports ) then
begin
Enum := Ports._NewEnum;
foreach := enum as IEnumVariant;
while foreach.Next(1, Port, PDWORD(0)^) = 0 do
begin
Desc := Port.Description; //str
Enabled := Port.Enabled; //bool
ExtIP := Port.ExternalIPAddress;//str
ExtPort := Port.ExternalPort; //int
IntClient := Port.InternalClient; //str
IntPort := Port.InternalPort; //int
Protocol := Port.Protocol; //str
temp := Desc + #9;
if enabled then
temp := temp + 'True' + #9
else
temp := temp + 'False' + #9;
temp := temp + ExtIP + #9 + IntToStr(ExtPort) + #9 +
IntClient + #9 + IntToStr(intPort) + #9 + Protocol + #13;
end;
end;当我在我的开发机器上运行它时,一切都很顺利.我看到路由器上的数据..。然而,我的开发机器只有一张网卡.我已经确定在生产机器(它有4个适配器.2物理和2虚拟) StaticPortMappingCollection总是空的。如何使用此功能并将其绑定到特定的卡上?
谢谢你提前..。
发布于 2014-09-08 03:06:38
HNetCfg.NATUPnP不支持您所要求的功能。您必须找到另一个uPNP实现(或编写您自己的)来控制套接字绑定。
https://stackoverflow.com/questions/25716778
复制相似问题