解析一个IP地址到主机名称
#include <Inet.au3>
_TCPIpToName($sIp [,$iOption = 0 [, $hDll_Ws2_32 = "Ws2_32.dll"]])
$sIp | 带点的IP(v4)地址格式. |
$iOption | [可选参数] 默认(Default) = 0 0 = 返回一个字符串主机名称 1 = 返回数组 (参考说明) |
$hDll_Ws2_32 | [可选参数] Ws2_32.dll 的句柄. |
成功: | 返回主机名或数组(见备注) | |
失败: | "" | |
@Error: | 0 = 无错误. | |
1 = inet_addr DllCall 失败 | ||
2 = inet_addr 失败 | ||
3 = gethostbyaddr DllCall 失败 | ||
4 = gethostbyaddr 失败, WSAGetLastError = @Extended | ||
5 = gethostbyaddr 失败, WSAGetLastError 失败 | ||
6 = strlen/sZStringRead 失败 | ||
7 = 读取别名数组时错误 |
#include <Array.au3>
#include <Inet.au3>
Global $aResult, $sResult, $sIP
; 示例 1
TCPStartup()
$sIP = TCPNameToIP("hiddensoft.com")
$sResult = _TCPIpToName($sIP)
If @error Then
MsgBox(4096, "_TCPIpToName()", "@error = " & @error & @LF & "@extended = " & @extended)
Else
MsgBox(4096, "hiddensoft.com really is:", $sResult)
EndIf
; 示例 2
TCPStartup()
$sIP = _GetIP()
$aResult = _TCPIpToName($sIP, 1)
If @error Then
MsgBox(4096, "_TCPIpToName()", "@error = " & @error & @LF & "@extended = " & @extended)
Else
_ArrayDisplay($aResult, "Local Hostname(s)")
EndIf