Created
May 29, 2012 05:11
-
-
Save hrstt/2822700 to your computer and use it in GitHub Desktop.
Excel VBAでnslookup ref: http://qiita.com/items/3dfc0bd2901b0a71c40c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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