[Truco Delphi] Cambiar la fecha del Sistema.
Descripcion:
Permite cambiar la fecha del Sistema.
delphi
function ChangeSystemDateTime(dtNeeded: TDateTime): Boolean; var tzi: TTimeZoneInformation; dtSystem: TSystemTime; begin GetTimeZoneInformation(tzi); dtNeeded := dtNeeded + tzi.Bias / 1440; with dtSystem do begin wYear := StrToInt(FormatDateTime('yyyy', dtNeeded)); wMonth := StrToInt(FormatDateTime('mm', dtNeeded)); wDay := StrToInt(FormatDateTime('dd', dtNeeded)); wHour := StrToInt(FormatDateTime('hh', dtNeeded)); wMinute := StrToInt(FormatDateTime('nn', dtNeeded)); wSecond := StrToInt(FormatDateTime('ss', dtNeeded)); wMilliseconds := 0; end; Result := SetSystemTime(dtSystem); end;
uso:
delphi
var fecha: TDateTime; begin fecha:= encodedate(1992,02,23); ChangeSystemDateTime(fecha); end;