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.