Hostname FQDN?

Does anyone know of a way to get the system host name as a Fully Qualified Domain name?
Both the System.EnvironmentVariable("COMPUTERNAME") and the Windows Functionality Suite GetHostName methods return the Host name only, not the FQDN.

Hi Tom,

Is this what your looking for?

msgbox System.Network.LookupDNSAddress("")

You can get the IP Address (instead of computer name) with


and put it all together with…

msgbox System.Network.LookupDNSAddress("COMPUTERNAME"))

YES! It’s the little things that make my day.


BTW, There is quite a bit of lag on my laptop with System.Network.LookupDNSAddress("COMPUTERNAME"))

The portion"COMPUTERNAME") is the culprit. Since I have multiple IP addresses on my laptop from a virtual interface, a wireless interface and a wired Ethernet interface I went this route for a default preferences selection using the highest number in the interface count. I haven’t tested it on any other systems yet but my app lets the user select the IP from a list derived from all the interfaces IP addresses

   Dim n As NetworkInterface
   Dim HostNameFQDN As String
   n = System.GetNetworkInterface(System.NetworkInterfaceCount - 1)
   HostNameFQDN = Lowercase(System.Network.LookupDNSAddress(n.IPAddress))

It returns the correct FQDN in milliseconds instead of seconds. I suppose I should trap for an interface less than zero but it’s an internal app and will never be installed on anything other than a server with at least 1 network interface.

Your code is nice and fast Tom. Thanks for optimizing it!