那位大侠能把下面的简单MAC地址扫描的速度优化,并附优化代码?
#include <inet.au3>$myname=""
;~ $_filename="E:\维护管理\安信工具\tools\ipset.ini"
$_filename="ipset.ini"
FileOpen ( $_filename, 1)
$_ip=IniRead ( $_filename, "改名信息", "ip", "192.168.1." )
ProgressOn("网吧MAC扫描", "Increments every second", "0 percent")
for $i=1 to 254
$mymac=_API_Get_NetworkAdapterMAC($_ip&$i)
ProgressSet( int($i/254*100),"扫描MAC: "&$_ip&$i ,"稍后就好.....")
if $mymac<>"00:00:00:00:00:00" then
IniWrite( $_filename, "MAC信息", "A"&$I,$mymac&" "&$myname )
EndIf
Next
FileClose( $_filename)
ProgressSet(100 ,"扫描:", "扫描完成")
sleep(2000)
Func _API_Get_NetworkAdapterMAC($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
If $s = "00:00:00:00:00:00"Then SetError(1)
Return $s
EndFunc ;==>_API_Get_NetworkAdapterMAC 没有办法?
还是要多线程? for里面调多个ping的函数,不过如果全部在线的话没什么意义,反而浪费
可以试试将254拆分开,每个函数扫描254/n个,可能会快很多。
代码自己研究去吧。。。。。。
[ 本帖最后由 ceoguang 于 2009-1-31 02:12 编辑 ]
页:
[1]