Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Cambiar fecha al pc (https://www.clubdelphi.com/foros/showthread.php?t=3430)

jgutti 06-09-2003 01:16:47

Cambiar fecha al pc
 
Hola al foro

Tengo un ejecutable que funciona con fecha inferior al año 2000,
por lo anterior necesito cambiar la fecha del Pc al ingresar al programa (12/12/1999) y al salir del programa volver a la fecha actual en el Pc (05/09/2003).

¿como puedo realizar este cambio?

desde ya gracias por la ayuda

atte

jgutti

Julià T. 06-09-2003 04:05:39

para cambiar a 1999

Var
DH:SystemTime;
begin
DateTimetoSystemTime(Now,DH);
DH.wYear:=1999;
SetLocalTime(DH);
end;


para volver a 2003

Var
DH:SystemTime;
begin
DateTimetoSystemTime(Now,DH);
DH.wYear:=2003;
SetLocalTime(DH);
end;

__hector 08-09-2003 21:29:15

Otra forma...

Código:

procedure TForm1.Button1Click(Sender: TObject);
var
  fecha:TSystemTime;
begin
  fecha.wyear:=1998;
  fecha.wMonth:=12;
  fecha.wDayofWeek:=5;
  fecha.wDay:=31;
  fecha.wHour:=15;
  Fecha.wMinute:=30;
  Fecha.wSecond:=0;
  Fecha.wMilliseconds:=0;
  if not SetSystemTime(Fecha) then
    showmessage('Error de cambio de fecha-hora');
end;



La franja horaria es GMT +2. Ahora son las 06:21:02.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi