如何获取网卡的MAC地址?
向各位高手求教 学会搜索。。。 $sIP = InputBox("MAC地址获取", "请输入IP地址", @IPAddress1, "", 150, 100, -1, -1)$MAC = _GetMAC ($sIP)
If $MAC <> "00:00:00:00:00:00" Then
MsgBox (0, "MAC地址", '"' &$sIP& '" 的MAC地址是:'&$MAC)
Else
MsgBox (0, "MAC地址", '无法获取:"' &$sIP& '" 的MAC地址')
EndIf
Func _GetMAC ($sIP)
Local $MAC,$MACSize
Local $i,$s,$r,$iIP
$MAC = DllStructCreate("byte")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize,1,6)
$r = DllCall ("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
$iIP = $r
$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 这个好啊.... :face (1):支持 可是为什么要先输入IP {:face (319):} 同求 回复 3# zw2725
这个很强,赞一个,实用! 嗯,问得好呢! 为什么要输入IP? Dim $MAC, $MACSize, $i, $sIP, $aR
$MAC = DllStructCreate("byte")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$aR = DllCall("Ws2_32.dll", "int", "inet_addr", "str", @IPAddress1)
$aR = DllCall("iphlpapi.dll", "int", "SendARP", "int", $aR1, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$sIP = ""
For $i = 0 To 5
If $i Then $sIP = $sIP & ":"
$sIP = $sIP & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
MsgBox(0, "MAC地址查看器", "mac地址为:" & $s) 感谢,感谢,感谢,感谢,好东西呀 谢谢楼主分享 回复 10# haijie1223
E:\au\ip\mac.au3(7,63) : WARNING: $aR1: 使用前并未进行声明.
$aR = DllCall("iphlpapi.dll", "int", "SendARP", "int", $aR1,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
E:\au\ip\mac.au3(13,45) : WARNING: $s: 使用前并未进行声明.
MsgBox(0, "MAC地址查看器", "mac地址为:" & $s)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
E:\au\ip\mac.au3(7,63) : 错误: $aR1: 未声明的全局变量.
$aR = DllCall("iphlpapi.dll", "int", "SendARP", "int", $aR1,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
E:\au\ip\mac.au3(13,45) : 错误: $s: 未声明的全局变量.
MsgBox(0, "MAC地址查看器", "mac地址为:" & $s)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
E:\au\ip\mac.au3 - 2 错误, 2 警告 回复 13# au3x
手误,自己改改就行了呗~Dim $MAC, $MACSize, $i, $sIP, $aR, $aR1
$MAC = DllStructCreate("byte")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$aR1 = DllCall("Ws2_32.dll", "int", "inet_addr", "str", @IPAddress1)
$aR = DllCall("iphlpapi.dll", "int", "SendARP", "int", $aR1, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$sIP = ""
For $i = 0 To 5
If $i Then $sIP = $sIP & ":"
$sIP = $sIP & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
MsgBox(0, "MAC地址查看器", "mac地址为:" & $sIP) 谢谢了喔,正要需要用到
页:
[1]