Skip to content

Instantly share code, notes, and snippets.

@hrstt
Created May 29, 2012 05:11
Show Gist options
  • Save hrstt/2822700 to your computer and use it in GitHub Desktop.
Save hrstt/2822700 to your computer and use it in GitHub Desktop.
Option Explicit
Function nslookup(ip As String) As String
Dim wsh, exec, cmd, res As String, i As Integer
Dim buf() As String
Set wsh = CreateObject("WScript.Shell")
cmd = "nslookup " & ip
Set exec = wsh.exec("%ComSpec% /c " & cmd)
Do While exec.Status = 0
DoEvents
Loop
res = exec.StdOut.ReadAll
buf = Split(res, vbCrLf)
For i = 0 To UBound(buf)
If Left(buf(i), 5) = "Name:" Or Left(buf(i), 3) = "名前:" Then
host_name = Mid(buf(i), 10)
End If
Next i
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment