Set the system time and date

Posted in System info

Use SystemTime structure for changing system date and time, and then use SetSystemTime procedure to set them into the system.

procedure TForm1.Button1Click(Sender: TObject);
var
  dt: TSystemTime;
begin
  dt.wYear:=1999;
  dt.wMonth:=2;
  dt.wDay:=25;
  dt.wHour:=9;
  dt.wMinute:=0;
  dt.wSecond:=0;
  dt.wMilliseconds:=0;
  if SetSystemTime(dt) then Label1.Caption:='Setting finished';
end;