VB6 reverse DNS

This page was imported from a much older version of my site. The contents are still relevant but haven't been changed in over five years. Please do us a favour and stop using VB6!

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.

Note: This code is for Visual Basic 6, not the more recent .NET versions

Usage

1
2
3
4
5
6
7
8
' Initialise Windows Sockets
InitWSA

' Attempt to get hostname
MsgBox GetHost("127.0.0.1")

' Cleanup Windows Sockets
Cleanup

Download code

Download the VB6 module - The code on its own
Download an example project - Shows how to use the code

One comment on “VB6 reverse DNS
  1. John Madden says:

    A great piece of code that runs faultlessly thousands of times.
    Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *

*