Network wake up program code
Published: 2005-01-06 11:15:20
I Depending on the network wake-up program written by the network wakeup packet, only the basic code parts are implemented, and the password cannot be sent. For Linux, there must be support for the libnet library. #include Void TwakeUponlanForm :: WakeremoteComputer (ANSISTRING ipaddress, unsigned char * macaddress) {unsigned char sendbuf [102]; for (int i = 0; i <102; i ) {sendbuf [i] = (i <6)? 0xff : Macaddress [i% 6];} TMEMORYSTREAM * MEMORYSTREAM = New TMEMORYSTREAM (); MemoryStream -> Clear (); MemoryStream -> Write (SendBuf, 102); nmudp1 -> remotehost = ipaddress; // Remove IP after the network The entire complement of segment 255 // 210.45.234.255 NMUDP1 -> SendStream (MemoryStream); delete MemoryStream;} unit WakeUp; interface uses Windows, Messages, SysUtils, Dialogs, WinSock; function CheckWinSockResult (ResultCode: Integer; const FuncName: string): Integer; procedure OpenComputer (SAddr: string); const LEN_PHYSADDR = 6; implementation {$ R * .DFM} function CheckWinSockResult (ResultCode: Integer; const FuncName: string): Integer; begin if Result Code <> 0 THEN BEGIN RESULT: = WSAGetLastError; showMessage (format (# 13 # 10'windows socket function ''% s' 'error:% s (% d)', [FuncName, SySerrorMessage (Result), Result]) Abort; Else Result: = 0; End; Procedure OpenComputer (Saddr: string); // 00-B0-D0-15-86-B4 Var Wsadata: Twsadata; Msocket: Tsocket; SockAddrin: TsockAddrin; RetVal, OptVal , i: integer; macaddr: array [0..5] of byte; MagicData: array [0..101] of byte; position: longint; begin tryness; for i: = 1 TO Length (Saddr) Do IF I in [3, 6, 9, 12, 15] Then IF Saddr [i] <