System.Net.Dns.GetHostEntry("localhost").AddressList(0).ToString
Technar писал(а):Нет мне именно надо личный ip-адрес компьютера!
как это зделать?
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic
Namespace Mssc
Module localIP
Dim ArrIP(0 To 20) As String
Class TestIPAddress
Private Shared Sub IPAddresses(ByVal server As String)
Dim I As Integer = 1
Try
Dim ASCII As New System.Text.ASCIIEncoding()
Dim heserver As IPHostEntry = Dns.GetHostEntry(server)
Dim curAdd As IPAddress
For Each curAdd In heserver.AddressList
ArrIP(I) = curAdd.ToString()
I = I + 1
Next curAdd
Catch e As Exception
Form1.ListBox1.Items.Add("[DoResolve] Exception: " + e.ToString())
End Try
End Sub
Shared Sub Main(ByVal args As String)
Dim server As String = Nothing
Dim rex As New Regex("^[a-zA-Z]\w{1,39}$")
If args.Length < 1 Then
server = Dns.GetHostName()
ArrIP(0) = server
Else
server = args(0)
If Not rex.Match(server).Success Then
Form1.ListBox1.Items.Add("Input string format not allowed.")
Return
End If
End If
IPAddresses(server)
ArrLIP = ArrIP ' передача во внешний масив всех данных!
End Sub 'Main
End Class 'TestIPAddress
End Module
End Namespace
Dim i As Net.IPHostEntry =Net.Dns.GetHostByName(Net.Dns.GetHostName)
MsgBox(i.AddressList(0).ToString)
Dim A As Net.NetworkInformation.NetworkInterface, B As Net.NetworkInformation.UnicastIPAddressInformation
For Each A In Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
For Each B In A.GetIPProperties.UnicastAddresses
MsgBox(B.Address.ToString)
Next
Next
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 91