procedure TForm1.Button1Click(Sender: TObject);
var
len: Integer;
ft: FileTime;
st: SystemTime;
TZI: _TIME_ZONE_INFORMATION;
begin
with TRegistry.Create do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('\SYSTEM\CurrentControlSet\Control\Windows', false);
len := GetDataSize('ShutDownTime');
ReadBinaryData('ShutdownTime', ft, len);
CloseKey;
Free;
end;
FileTimeToSystemTime(ft, st);
GetTimeZoneInformation(TZI);
SystemTimeToTzSpecificLocalTime(@TZI, st, st);
ShowMessage(FormatDateTime('"上次关机时间: "yyyy年m月d日 ddddampm hh点m分s秒z毫秒',
SystemTimeToDateTime(st)));
end;