What is the command to display computer name & ip address ?

E

Eng Teng

What is the command to display computer name & ip address in VB.NET 2005 (OS
WindowsXP & Windows Vista)


Regards,
Tee
 
K

kimiraikkonen

What is the command to display computer name & ip address in VB.NET 2005 (OS
WindowsXP & Windows Vista)

Regards,
Tee

Hi Eng,
For short ways,

' To display computer name:

My.Computer.Info.OSFullName

' To display local IP:
Imports System.net
Module Module1

Sub Main()
'To get local address
Dim sHostName As String
Dim i As Integer
sHostName = Dns.GetHostName()
Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName)
Dim IpA() As IPAddress = ipE.AddressList
For i = 0 To IpA.GetUpperBound(0)
Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString)
Next

Console.ReadLine()
End Sub
End Module


Hope this helps,

Onur Güzel
 
E

Eng Teng

How about Service Pack info ?

What is the command to display computer name & ip address in VB.NET 2005
(OS
WindowsXP & Windows Vista)

Regards,
Tee

Hi Eng,
For short ways,

' To display computer name:

My.Computer.Info.OSFullName

' To display local IP:
Imports System.net
Module Module1

Sub Main()
'To get local address
Dim sHostName As String
Dim i As Integer
sHostName = Dns.GetHostName()
Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName)
Dim IpA() As IPAddress = ipE.AddressList
For i = 0 To IpA.GetUpperBound(0)
Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString)
Next

Console.ReadLine()
End Sub
End Module


Hope this helps,

Onur Güzel
 
K

kimiraikkonen

How about Service Pack info ?





Hi Eng,
For short ways,

' To display computer name:

My.Computer.Info.OSFullName

' To display local IP:
Imports System.net
Module Module1

Sub Main()
'To get local address
Dim sHostName As String
Dim i As Integer
sHostName = Dns.GetHostName()
Dim ipE As IPHostEntry = Dns.GetHostByName(sHostName)
Dim IpA() As IPAddress = ipE.AddressList
For i = 0 To IpA.GetUpperBound(0)
Console.Write("IP Address {0}: {1} ", i, IpA(i).ToString)
Next

Console.ReadLine()
End Sub
End Module

Hope this helps,

Onur Güzel

To get Service Pack version,
simply use;

Environment.OSVersion.ServicePack

Hope this helps,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top