Examples Delphi

-set time
procedure TForm1.Button1Click(Sender: TObject);
var
SystemTime : TSystemTime;
begin
SystemTime.wHour := 23;
SystemTime.wMinute := 20;
SystemTime.wSecond := 0;
SetLocalTime(SystemTime);
end;
------------------------------------------------------------
-set date
procedure TForm1.Button2Click(Sender: TObject);
var
SystemTime : TSystemTime;
begin
SystemTime.wYear := 2000;
SystemTime.wMonth := 5;
SystemTime.wDay := 23;
SetLocalTime(SystemTime);
end;
--------------------------------------------------------------
- time since last boot
function Uptime: string;
var
count,
days,
min,
hours,
seconds : longint;
begin
{Obtenemos milisegundos transcurridos}
{Gets windows uptime in msec}
Count := GetTickCount();
{Lo convertimos a dd-hh-mm-ss}
{Coverts msec into dd-hh-mm-ss}
Count := Count div 1000;
Days := Count div (24 * 3600);
if Days > 0 then
Count := Count - (24 * 3600 * Days);
Hours := Count div 3600;
if Hours > 0 then
Count := Count - (3600 * Hours);
Min := Count div 60;
Seconds := Count mod 60;
{Damos el resultado, en una string}
{Gives the result and converts it into string}
Result := IntToStr(Days)+' Days '+IntToStr(Hours)+
' hours '+IntToStr(Min)+' minutes '+
IntToStr(seconds) +' seconds ';
end;
begin
Label1.Caption:=Uptime;
end;
--------------------------------------------------------------