質問です
VBからnslookup ***(←ここは任意の文字)コマンドを使って、
かつ、その結果(IP)をパラメータで得たいのですが
方法を教えて下さい。お願いします。
環境は6.0.xpです。
WindowsXPでは動きました。
Dim WshShell
Dim oExec
Dim sInput
Dim parm
Dim IP
parm = ""
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("nslookup" & " " & parm)
Set Reg = CreateObject("VBScript.RegExp")
Reg.Pattern = "(Address *)(.*)"
sInput = ""
Do While True
If Not oExec.StdOut.AtEndOfStream Then
sInput = oExec.StdOut.ReadLine
MsgBox sInput
If Reg.TEST(sInput) = True Then
IP = Reg.Replace(sInput, "$2")
MsgBox IP
Exit Do
End If
Else
Exit Do
End If
Loop
もうちょっと直接的な方法:
http://wisdom.sakura.ne.jp/system/winapi/winsock/winSock3.html
のgethostbyname()、gethostbyaddr()
>のgethostbyname()、gethostbyaddr()
これだとDNSサーバーを指定する場合は
もうちょっと考える必要がありますね。
確かに(orz
ちょとお修正・・
>Reg.Pattern = "(Address *)(.*)"
Reg.Pattern = "(Address: *)(.*)"
ツイート | ![]() |