Function: Let the computer shut down a key to boot, need the target computer motherboard support, and plug in the network cable;
Effect: the equivalent of manually pressing the target computer's switch button.
No technical content, simple came David ...
1. Get the target MAC address
Qbytearray smacaddr ("00-1f-16-26-d5-73");
2. Package Magic Package Chmagicpacket
Char chmacaddr[9];//should be 6 characters, but if you write 6 characters, the following sscanf_s will error, so write a large point char chmagicpacket[104]; const char *lpmacaddr=smacaddr.data (); sscanf_s (lpmacaddr, "%2x-%2x-%2x-%2x-%2x-%2x", &chmacaddr[0],&chmacaddr[1],&chmacaddr[2], &CHMACADDR[3],&CHMACADDR[4],&CHMACADDR[5]); memset (chmagicpacket,0xff,6); int packetsize=6; for (int i=0;i<16;i++) { memcpy (chmagicpacket+packetsize,chmacaddr,6); packetsize+=6; }
3. Send a magic Packet
Udpsocket.writedatagram (Chmagicpacket, 102, qhostaddress ("255.255.255.255"), 50209);
Http://www.cnblogs.com/luoxiang/p/5413096.html
QT uses WOL to enable remote one-click Boot (LAN, requires the target computer's motherboard support, and plug in the network cable)