AddUPnPEntry()
uses the IStaticPortMappingCollection.Add()
method. There is an associated IStaticPortMappingCollection.Remove()
method, eg:
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);