problem determining local IP address correctly
Posted on 2000-02-29
This one is driving me nuts.... I'm working on a GUI which configures a network element. On connect, I need to write the local IP of the PC the gui's running on to a table on the network element, so it will send state change traps to a certain port on the PC.
Anyway, I'm writing in visual basic and it ordinarily works fine through a VB function to get the local IP address. There is a problem when you have a laptop, for instance, which is configured for a static IP through a ethernet port, but also has a modem. If you try to dial up and get a DHCP address, windows gets confused when I ask for the local IP and always returns whatever the static IP is, even when that interface is not in use (i'm dialed-up and ethernet cable disconnected).
I got some code to call the windows API directly, thinking it was a VB bug, but get the same result.
Does anyone know how to get the correct IP in this situation--I need the DHCP address in order that the traps go to the right location.