Link to home
Start Free TrialLog in
Avatar of chaos_59
chaos_59

asked on

How can I get a list of ip addresses on my local pc?

I want to be able to get a list of the ip addresses for ll of the NICs in my pc. Currently I have 2 NICs in my pc. The ip address for 1 is fixed, 192.168.128.xxx, the other ip address is set by dhcp and not stable.
I know I could shell out to IPCONFIG and redirect the output to a file and parse it out to get the ip addresses. But this doesn't seem like a good solution to me.
Any ideas?
Avatar of RichW
RichW
Flag of United States of America image

Why not use a Winsock control, set the port on it and do something like:
Text1.Text = Winsock1.LocalIP
Text2.Text = Winsock1.LocalHostName
RichW
ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chaos_59
chaos_59

ASKER

Rich, I am using a winsock control. But I am using 2 network cards (NICs). The winsock control returns the ip address of only one of the network cards. I tried setting one of the winsock controls to the ip address of one of the cards, hoping that the other winsock control would default to the 2nd network card. But they both returned the same ip address.
Why don't you just set the IPs in the winsock control once you have determined the IPs using the sample given by Richie...???

Cheers...
Ber...
Ber,
I want to be able to get a list of IP addresses. I know what MY ip addresses are now, one is fixec, but the other could change within the week. I don't want to have to change the application every time my ip address changes. Also, if I move this application to another pc I don't want to have to reconfigure it. It's just a lot cleaner if the application can find the correct ip address without having any user intervention.
Thanks Richie,
I would have preferred a simpler solution to this. I don't really like api programming, but I'll take what I can get.
Thanks.
Sometimes, there is no other way that API's way (thanks to God that they exist ;). Unfortunately, some goals are impossible with vb "standard" code.
Thanks for "A" grade!