unit uWakeOnLan;
interface
uses
WinTypes, Messages, SysUtils, Classes, IdBaseComponent,
IdComponent, IdUDPBase, IdUDPClient, IdGlobal;
procedure WakeUPComputer(aMacAddress:
string);
implementation
procedure WakeUPComputer(aMacAddress:
string);
var
Data:
string;
temp:
string;
k, n: integer;
idUDPClient: TIdUDPClient;
begin
try
SetLength(Data, 255);
for k := 0
to 5
do
begin
Data := Data + Chr(StrToInt('
$FF'));
// 6x add a FF / 6x ein FF hinzufügen
end;
temp := StringReplace(aMacAddress, '
-', '
', [rfReplaceAll]);
for k := 0
to 15
do
begin
temp := StringReplace(aMacAddress, '
-', '
', [rfReplaceAll]);
for n := 0
to 5
do
begin
// 16x add Target-Mac-Adress / 16x die Ziel-Macadresse hinzufügen
Data := Data + Chr(StrToInt('
$' + temp[1] + temp[2]));
Delete(temp, 1, 2);
end;
end;
try
idUDPClient := TIdUDPClient.Create(
NIl);
idUDPClient.BroadcastEnabled := true;
idUDPClient.Host := '
255.255.255.255';
idUDPClient.Port := 80;
idUDPClient.Send(Data);
finally
FreeAndNil(idUDPClient);
end;
except
end;
end;
end.