Ir al contenido


Foto

[Truco Delphi] Cambiar la fecha del Sistema.


  • Por favor identifícate para responder
No hay respuestas en este tema

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 17 agosto 2016 - 04:45

[Truco Delphi] Cambiar la fecha del Sistema.

 

Descripcion:

Permite cambiar la fecha del Sistema.


delphi
  1. function ChangeSystemDateTime(dtNeeded: TDateTime): Boolean;
  2. var
  3. tzi: TTimeZoneInformation;
  4. dtSystem: TSystemTime;
  5. begin
  6. GetTimeZoneInformation(tzi);
  7. dtNeeded := dtNeeded + tzi.Bias / 1440;
  8. with dtSystem do
  9. begin
  10. wYear := StrToInt(FormatDateTime('yyyy', dtNeeded));
  11. wMonth := StrToInt(FormatDateTime('mm', dtNeeded));
  12. wDay := StrToInt(FormatDateTime('dd', dtNeeded));
  13. wHour := StrToInt(FormatDateTime('hh', dtNeeded));
  14. wMinute := StrToInt(FormatDateTime('nn', dtNeeded));
  15. wSecond := StrToInt(FormatDateTime('ss', dtNeeded));
  16. wMilliseconds := 0;
  17. end;
  18. Result := SetSystemTime(dtSystem);
  19. end;

uso:


delphi
  1. var
  2. fecha: TDateTime;
  3. begin
  4. fecha:= encodedate(1992,02,23);
  5. ChangeSystemDateTime(fecha);
  6. end;


  • 2




IP.Board spam blocked by CleanTalk.