Link to home
Start Free TrialLog in
Avatar of dynamicrevolutions
dynamicrevolutions

asked on

How to get server or localhost address in VB.net Win32 application.

Hi..

How do i get a server IP address in VB.net win32 application.

Thanks !
ASKER CERTIFIED SOLUTION
Avatar of pfransson
pfransson

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 bhpr
bhpr

Hi dynamicrevolutions,

try this...

Import System.Net

 Dim ipEntry As IPHostEntry = Dns.GetHostByName(Environment.MachineName)
 Dim IpAddr As IPAddress() = ipEntry.AddressList
 Dim i As Integer

 'A hostmachine can have more than one IP assigned

  Me.Label2.Text = IpAddr(0).ToString()

-bhpr
hey..

check if this is what you are looking for..

        Dim ip As System.Net.IPHostEntry
        ip = System.Net.Dns.GetHostByName("<server name>")
        MsgBox(ip.AddressList(0).ToString) 'will display the first IP assigned


you might hav eto add error checks

Enjoy!
Pratap
oops.. sorry guys.. i din't notice your posts..