用论坛上的MAC地址获得函数,IP10.120.197.1-10.120.197.192都是错的,10.12.197.193开始才对,为啥的,求高手指教Func _GetMAC($sIP)
Local $MAC, $MACSize
Local $i, $s, $r, $iIP
$MAC = DllStructCreate("byte[6]")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$r = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
$iIP = $r[0]
$r = DllCall("iphlpapi.dll", "int", "SendARP", "int", $iIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$s = ""
For $i = 0 To 5
If $i Then $s = $s & "-"
$s = $s & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
Return $s
EndFunc ;==>_GetMAC
Func _StringIsIP($strIP)
$str = StringSplit($strIP, ".")
If $str[0] <> 4 Then
Return ("")
ElseIf StringIsDigit($str[1]) <> 1 Or StringIsDigit($str[2]) <> 1 Or StringIsDigit($str[3]) <> 1 Or StringIsDigit($str[4]) <> 1 Then
Return ("")
ElseIf $str[1] > 255 Or $str[2] > 255 Or $str[3] > 255 Or $str[4] > 255 Then
Return ("")
Else
$strIP = Int($str[1]) & "." & Int($str[2]) & "." & Int($str[3]) & "." & Int($str[4])
Return $strIP
EndIf
EndFunc
|