?: How 2 find system IP Addr (tricky tricky)
Question: How do I find the PC's IP Address? This
gets especially tricky on systems with more than one
network interface (i.e. a PC with a ethernet card
would have an IP address for that card, but the user
might also want to use dial-up networking). I have a
couple of possible partial solutions: First, the
registry contains information on each network transport
you specify in the control panel under "network."
The registry key is:
\HKEY_Local_Machine\System\CurrentControlSet\Services\Class\NetTrans\xxxx
(where xxxx is a number 0000-9999). If the key contains
"TCP/IP" in the DriverDesc, then it will have another
item called "IPAddress." This item is a string containing
the IP Address in dotted decimal notation. But if you specify
"Obtain an IP Address Automatically" under the TCP/IP Properties
page (back in the control panel under "network"), the IP Address
will be 0.0.0.0. This is usually the case for dial-up
networking, but is also often the case when an ethernet
network is setup to use DHCP.
Another semi-useful solution is to system() a netstat -na
command which will return a list of all waiting listeners
and established connections. This doesn't help unless
the some program is connected or waiting for connections.
So the question remains: for those interfaces which use DHCP
or get their IP Address from the PPP server, how can I get the
IP Address?
Please CC me by email if you have any ideas. I'll be monitoring
the newsgroup, but it can get a little cluttered.
-Michael Cooper.
aur...@nr.infi.net