If you go to Start and click Computer and then click on the Network link on the left hand side, you’ll notice on the right hand side several categories, one of which is titled "Network Infrastructure", in that category, my router is listed, and in my case, it is "LINKSYS WAG160N Wireless-N ADSL2+ Gateway" and when you right-click and select properties, it lists basic info such as internal/gateway IP address, on mine it is "192.168.1.1"
I would like to know how to retrieve this information in code, preferably a Windows API so that I can call it using a legacy VB6 app. Also, even if you just know a .NET version or a Delphi version, please do list that as well as I can code in both. However, the answer I’m ultimately seeking is a method to access this via VB6 so that would probably be a WinAPI call, however, other methods are also welcome in case I can’t find a legacy method.
There is a bit more code required than I’d like. If there is a more compact approach I’d be interested myself.
As I understand this, Windows gets the information via UPnP. UPnP works as a sort of Web Service over UDP. It has quirks because it uses UDP multicasts so it can be dificult to code explicitly, but Windows offers a helper library. This library is not “wrapped” well for use from a VB6 program, but with a few tricks you can get access to most of its functionality.
The sample below is written so that it can compile on Win XP as well as later versions of Windows. The Win XP version of the library lacks critical typelib info that prevents VB6 from using everything it offers. This was corrected in Vista, however for this application we don’t need the full callback capabilities it offers. You could use an external typelib if you needed full access, or you can compile on Vista or later. A progam compiled on Vista works fine on XP.
The code below is abstracted from a larger Class I use for UPnP NAT port mapping in VB6 servers. This subset may do what you require though.
UPnPNAT.cls
UPnPNATCBs.cls
Form1.frm
You may have to tweak this some if you have multiple UPnP devices providing connections in your network.