Ben,
You have a couple options.
You could use PInvoke for the following signature:
Private Declare Function NetGetDCName Lib "netapi32.dll" (ByVal
strServerName As Object, ByVal strDomainName As Object, ByVal pBuffer As
Long) As Long
You could use the System.Net namespace:
Dim MYIP As System.Net.IPHostEntry =
System.Net.Dns.GetHostEntry(My.Computer.Name)
Dim IPaddress As String = MYIP.AddressList.GetValue(0).ToString
Console.WriteLine(System.Net.Dns.GetHostEntry(IPaddress).HostName)
You could also use the System.Net.NetworkInformation namespace for the long
way around, but more detail. Check out this code:
Imports System.Net
Imports System.Net.NetworkInformation
Public Class NetworkInfo
Public Shared Sub ShowIPAddresses()
Dim computerProperties As IPGlobalProperties =
IPGlobalProperties.GetIPGlobalProperties()
Dim nics() As NetworkInterface =
NetworkInterface.GetAllNetworkInterfaces()
Console.WriteLine("Interface information for {0}.{1} ", _
computerProperties.HostName, computerProperties.DomainName)
If (nics Is Nothing OrElse nics.Length < 1) Then
Console.WriteLine(" No network interfaces found.")
Return
End If
Console.WriteLine(" Number of interfaces .................... :
{0}", nics.Length)
For Each adapter As NetworkInterface In nics
Dim adapterProperties As IPInterfaceProperties =
adapter.GetIPProperties()
Dim dnsServers As IPAddressCollection =
adapterProperties.DnsAddresses
If (Not dnsServers Is Nothing) Then
For Each dns As IPAddress In dnsServers
Console.WriteLine(" DNS Servers
.............................. : {0}", dns.ToString())
Console.WriteLine(" Server Name
........................... : {0}",
System.Net.Dns.GetHostEntry(dns.ToString).HostName)
Next
End If
Next
End Sub
End Class
You could also use the registry:
http://www.java2s.com/Code/CSharp/Network/FindDNSServers.htm
Hope this helps,
Steve