Einzelnen Beitrag anzeigen

berens

Registriert seit: 3. Sep 2004
431 Beiträge
 
Delphi 2010 Professional
 
#2

Re: Wake On Lan (WOL) für Delphi 2007 / Indy

  Alt 3. Jul 2007, 10:43
Habe das Problem lösen können, unter anderem mit Hilfe von http://www.swissdelphicenter.ch/torr...de.php?id=1556 .

Hier die komplette Unit, vielleicht mag das ja mal jemand als Aktualisierung in die Library hinzufügen:

Delphi-Quellcode:
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.
  Mit Zitat antworten Zitat