官方的UDF可能有问题,GenerateMagicPacket()中,
$MACData 为空,$MagicPacket 为空
无法实现网络唤醒,
但下载专业的网络唤醒软件就可以哦.
$IPAddress = "172.16.1.255"; This is the broadcast address !
$MACAddress = "001122334455"
UDPStartUp()
$connexion = UDPOpen($IPAddress, 7)
$res = UDPSend($connexion, GenerateMagicPacket($MACAddress))
MsgBox(0, "", $res)
UDPCloseSocket($connexion)
UDPShutdown()
; ===================================================================
; Functions
; ===================================================================
; This function convert a MAC Address Byte (e.g. "1f") to a char
Func HexToChar($strHex)
Return Chr(Dec($strHex))
EndFunc
; This function generate the "Magic Packet"
Func GenerateMagicPacket($strMACAddress)
$MagicPacket = ""
$MACData = ""
For $p = 1 To 11 Step 2
$MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2))
Next
MsgBox(0,"mac",$MACData) ;$MACData 为空
For $p = 1 To 6
$MagicPacket = HexToChar("ff") & $MagicPacket
Next
MsgBox(0,"magicpacket", $MagicPacket) ;$MagicPacket 为空
For $p = 1 To 16
$MagicPacket = $MagicPacket & $MACData
Next
MsgBox(0,"magicpacket1",$MagicPacket) ;$MagicPacket 为空
Return $MagicPacket
EndFunc
[ 本帖最后由 nodisk 于 2008-8-18 13:10 编辑 ] |