设置和获得时间
procedure TForm1.GetLocalTimeButtonClick(Sender: TObject);
var
SystemTime: TSystemTime;
begin
GetLocalTime(SystemTime);
YearEdit.Text := IntToStr(SystemTime.wYear);
MonthEdit.Text := IntToStr(SystemTime.wMonth);
DayEdit.Text := IntToStr(SystemTime.wDay);
HourEdit.Text := IntToStr(SystemTime.wHour);
MinuteEdit.Text := IntToStr(SystemTime.wMinute);
SecondEdit.Text := IntToStr(SystemTime.wSecond);
end;
procedure TForm1.SetLocalTimeButtonClick(Sender: TObject);
var
SystemTime: TSystemTime;
begin
FillChar(SystemTime, SizeOf(SystemTime), 0);
SystemTime.wYear := StrToIntDef(YearEdit.Text, 0);
SystemTime.wMonth := StrToIntDef(MonthEdit.Text, 0);
SystemTime.wDay := StrToIntDef(DayEdit.Text, 0);
SystemTime.wHour := StrToIntDef(HourEdit.Text, 0);
SystemTime.wMinute := StrToIntDef(MinuteEdit.Text, 0);
SystemTime.wSecond := StrToIntDef(SecondEdit.Text, 0);
SetLocalTime(SystemTime);
end;