|
论坛里的网络唤醒,为什么我试了,发现根本唤醒不了啊.. 返回值:86.
我的IP是:192.168.0.8
目标机器是:192.168.0.9.
说明:目标网络唤醒功能没有问题,因为我用:magic_pkt 工具能够唤醒. 请高人指点.
以下是论坛中的代码,谢谢!!
------------
$IPAddress = "192.168.0.8"; 这是广播地址 !
$MACAddress = "001c610000bc";这是mac地址
UDPStartUp();开始 UDP 服务.
$connexion = UDPOpen($IPAddress, 7);连接到服务器进行会话,port为7赋给变量"$connexion"
$res = UDPSend($connexion, GenerateMagicPacket($MACAddress)) ;打开的套接字(socket)上面发送数据,GenerateMagicPacket($MACAddress)调用函数
MsgBox(0, "", $res);测试是否发送成功,失败为0
UDPCloseSocket($connexion) ;关闭一个 UDP (socket).
UDPShutdown() ;停止 UDP 服务.
; ===================================================================
; 函数 *=== 转换的MAC地址 为ASCII码所对应的字符 ===*
; ===================================================================
Func HexToChar($strHex)
Return Chr(Dec($strHex)) ;返回指定ASCII码所对应的字符"Dec($strHex)返回某十六进制数的十进制数值
EndFunc
; 此功能返回生成 "数据包"
Func GenerateMagicPacket($strMACAddress)
$MagicPacket = ""
$MACData = ""
For $p = 1 To 11 Step 2;循环取MAC值
$MACData = $MACData & HexToChar(StringMid($strMACAddress, $p, 2));StringMid取 "MAC"字符传递给函数"HexToChar"做实参
Next
For $p = 1 To 6 ;
$MagicPacket = HexToChar("ff") & $MagicPacket
Next
For $p = 1 To 16
$MagicPacket = $MagicPacket & $MACData
Next
Return $MagicPacket
EndFunc |
|