Navigation: home » code » vbreversedns

Reverse DNS (VB Function)

Looking up an IP from a hostname is fairly easy in Visual Basic but resolving IP addresses to hostnames isn’t. However, IN PTR DNS records can be retrieved using the Winsock APIs quite easily.

The example contains a simple project that simply shows how to call the function and how to handle errors.

Usage:

' Initialise Windows Sockets
InitWSA
    
' Attempt to get hostname
MsgBox GetHost("127.0.0.1")
 
' Cleanup Windows Sockets
Cleanup

Download

The files available for this release are below.

File Description
modReverseDNS.basVB Module - A .bas module file containing the necessary functions.
ReverseDNS.zipExample project - A zipfile containing a sample project using the above code, and a compiled demo exe.