网络远程唤醒是通过MAC地址来控制的, 包的格式很简单,在以太网包的任何位置上, 以6个FF为先导,后面跟相应MAC地址重复16次即可:
FF FF FF FF FF FF 08 65 88 a0 00 38 ... ... 08 65 88 a0 00 38 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 重复16次
当然,网卡必须支持这种协议,主板/电源也必须支持网络唤醒
下面是代码 procedure TForm1.Button1Click(Sender: TObject); var SendCode:string; TempStr:string; i:byte; begin SendCode:=StringofChar(#255,6); for i:=0 to 15 do begin TempStr:=TempStr +string(char($00)) +string(char($50)) +string(char($BA)) +string(char($EC)) +string(char($71)) +string(char($A6)); end; SendCode:=SendCode+TempStr; UDPSend(SendCode); end; procedure TForm1.UDPSend(SendCode: String); var SendMStream:TMemoryStream; begin SendMStream:=TMemoryStream.Create; try NMUDP1.ReportLevel:=1; NMUDP1.RemoteHost:=\'188.0.255.255\'; NMUDP1.RemotePort:=7010; SendMStream.Write(SendCode[1],length(SendCode)); NMUDP1.SendStream(SendMStream); finally SendMStream.Free; end; end;
|