在Inno Setup脚本中,我有一个从当前时间创建的字符串,该字符串存储在注册表中。我喜欢这样:
function GetInstallDateTime (s : String ) : String;
Var
year, month, day, nr1, nr2 : String;
sum : Byte;
error: Integer;
begin
year := GetDateTimeString ('yy', #0, #0);
nr1 := Copy(year, 1, 1);
nr2 := Copy(year, 2, 1);
year := nr1+nr2;
month := GetDateTimeString ('mm', #0, #0);
nr1 := Copy(month, 1, 1);
nr2 := Copy(month, 2, 1);
month := nr1 + nr2;
day := GetDateTimeString ('dd', #0, #0);
nr1 := Copy(day, 1, 1);
nr2 := Copy(day, 2, 1);
day := nr1 + nr2;
hour := GetDateTimeString ('hh', #0, #0);
nr1 := Copy(hour, 1, 1);
nr2 := Copy(hour, 2, 1);
hour := nr1 + nr2;
Result := year + month + day + hour);
end;
[Registry]
Root: HKLM; Subkey: "Software\Testprogram\Settings"; ValueType: string; \
ValueName: "mrg"; ValueData: {code:GetInstallDateTime|''}; \
Flags: deletekey;
问题是我需要使用UTC时间制作字符串。有谁能告诉我我该怎么做?
谢谢。
答案 0 :(得分:0)
您已经知道(基于您的alternative attempt),您可以使用GetSystemTime
WinAPI function:
type
TSystemTime = record
wYear: Word;
wMonth: Word;
wDayOfWeek: Word;
wDay: Word;
wHour: Word;
wMinute: Word;
wSecond: Word;
wMilliseconds: Word;
end;
procedure GetSystemTime(var lpSystemTime: TSystemTime);
external 'GetSystemTime@kernel32.dll';
function GetInstallDateTime(Param: string): string;
var
SystemTime: TSystemTime;
begin
GetSystemTime(SystemTime);
Result :=
Format('%.2d%.2d%.2d%.2d', [
SystemTime.wYear mod 100, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour]);
end;