Ver Mensaje Individual
  #5  
Antiguo 07-04-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola jhonalone.

¿ Que motivo tendría para castigarte ?

Estuve investigando si alguna función del API te podría servir y creo que [NetRemoteTOD], podría funcionar:

Código Delphi [-]
...
implementation

uses DateUtils;

type
  PTimeOfDayInfo = ^TTimeOfDayInfo;

  TTimeOfDayInfo = record
    todElapsedt: DWORD;
    todMSecs: DWord;
    todHours: DWord;
    todMins: DWord;
    todSecs: DWord;
    todHunds: DWord;
    todTimeZone: LongInt;
    todTInterval: DWord;
    todDay: DWord;
    todMonth: DWord;
    todYear: DWord;
    todWeekday: DWord;
  end;

function NetRemoteTOD(UncServerName: PWideChar; var TimeOfDayInfo: PTimeOfDayInfo): DWORD; stdcall; 
  external 'NetAPI32.dll';

function GetServerDateTime(ServerName: WideString): TDateTime;
var
  tod: PTimeOfDayInfo;
  PWChar: PWideChar;
  tZone: Integer;
  Dt: TDate;
  Ti: TTime;
begin
  PWChar:= @ServerName[1];
  if NetRemoteTOD(PWChar, tod) = 0 then
  begin
    if tod.todTimeZone <> -1 then
      tZone:= tod.todTimeZone div 60
    else
      tZone:= 0;
    try
      Dt:= EncodeDate(tod.todYear, tod.todMonth, tod.todDay);
      Ti:= EncodeTime(tod.todHours, tod.todMins, tod.todSecs, 0)
    except
      raise Exception.Create('Respuesta erronea del servidor')
    end;
    Result := Dt + Ti - tZone / 24
  end
  else
    raise Exception.Create('Error al requerir datos de '+PWChar)
end;

Llamada de ejemplo:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(DateTimeToStr(GetServerDateTime('\\DESKTOP')));
end;

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 07-04-2012 a las 08:11:49.
Responder Con Cita