Well I'm not sure how I missed it, but as it happens even that is more effort than really required. It turns out there are more VB-friendly interfaces available, and they work even in XP if the user has the necessary components installed. This MS KB article helps XPers get up to speed:
Vista and Win7 generally install the necessary items with no special effort on the user's part.
The NATUPnP Typelib
Well it turns out there is another typelib you can use. The result is that you can add and remove "port mappings" ("port forwardings?") and get the external IP address of your router with relative ease.
With more effort you can do things like enumerate the existing port mappings to avoid potential collisions and be notified is the external IP address changes on you during a run. These aren't needed by most programs though, so we can keep things simple here.
Stripping out the UI management logic, the attached demo is doing just a few things:
Bare Bones: Adding a Mapping & Retrieving External IP
Code:
Private Sub cmdAdd_Click()
Dim UPnPNAT As NATUPNPLib.UPnPNAT
Dim StaticPortMapping As NATUPNPLib.IStaticPortMapping
Set UPnPNAT = New NATUPNPLib.UPnPNAT
On Error Resume Next
Set StaticPortMapping = _
UPnPNAT.StaticPortMappingCollection.Add(CLng(txtExtPort.Text), _
"UDP", _
CLng(txtIntPort.Text), _
Winsock.LocalIP, _
True, _
"Demo Port Mapping")
If Err Then
MsgBox CStr(Err.Number)
Else
On Error GoTo 0
MsgBox "Success!"
ExternalIPAddress = StaticPortMapping.ExternalIPAddress
End Sub
Bare Bones: Removing a Port Mapping
Code:
Private Sub cmdRemove_Click()
Dim UPnPNAT As NATUPNPLib.UPnPNAT
Set UPnPNAT = New NATUPNPLib.UPnPNAT
On Error Resume Next
UPnPNAT.StaticPortMappingCollection.Remove CLng(txtExtPort.Text), "UDP"
If Err Then
MsgBox CStr(Err.Number)
Else
On Error GoTo 0
MsgBox "Success!"
End If
End Sub
The Demo
In the demo program attached here, you specify your external and internal port numbers. Then click Add to add the mapping, and click Ping as many times as you like to send yourself a UDP "ping" message via the external IP address and external port. Finally click Remove to remove the mapping.
Your router's logs should show these add/remove actions too.
Pretty basic.
Note
Firewall rules on the PC are another story. Yes, there is another set of interfaces for opening access to your program. Yes, they require admin rights in order to succeed - unlike port mapping.
The recommendation is that you set up the firewall rules required during installation. Port mappings should be more dynamic though, since small routers normally support a fairly limited total number of mappings. Depending on how you use the ports the user will generally get a firewall prompt on the first run anyway.