如何存储日期和注册表中安装时间

 
 
;
; ISX 3.0.6
;
;
[Setup]
AppName=DateTimeReg
AppVerName=DateTimeReg
Uninstallable=false
UpdateUninstallLogAppName=false
DisableDirPage=true
DisableProgramGroupPage=true
DefaultDirName={pf}\DateTimeReg
DisableStartupPrompt=true
[Registry]
Root: HKLM; Subkey: Software\MyCompany\MyProgram; ValueType: string; ValueName: DateTimeInstall; ValueData: {code:GetMyStringNow|''}
[_ISTool]
EnableISX=true

[Code]

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
'[email protected]';
procedure GetLocalTime(var lpSystemTime: TSystemTime); external
'[email protected]';
// variable to store date time infos
var
  st, lt: TSystemTime;

function FormatDateTime( dt: TSystemTime ) : String;
begin
  Result := IntToStr( dt.wDay )+'/'+IntToStr( dt.wMonth )+'/'+IntToStr( dt.wYear ) +
    '  '+IntToStr( dt.wHour )+':'+IntToStr( dt.wMinute )+'.'+IntToStr( dt.wSecond );
end;
function FormatANSI( dt: TSystemTime ) : String;
var s: String;
begin
  Result := IntToStr( dt.wYear );
  s := IntToStr( dt.wMonth ); if length(s) = 1 then s := '0' + s;
  Result := Result + s;
  s := IntToStr( dt.wDay ); if length(s) = 1 then s := '0' + s;
  Result := Result + s;
  s := IntToStr( dt.wHour ); if length(s) = 1 then s := '0' + s;
  Result := Result + s;
  s := IntToStr( dt.wMinute ); if length(s) = 1 then s := '0' + s;
  Result := Result + s;
  s := IntToStr( dt.wSecond ); if length(s) = 1 then s := '0' + s;
  Result := Result + s;
end;
function GetMyStringNow( s : String ) : String;
begin
 Result := FormatANSI( lt );
end;

function InitializeSetup: Boolean;
var
  s, crlf: string;
begin
  crlf := #13#10;
  GetSystemTime(st);
  GetLocalTime(lt);
  s := 'System Time is : ' + crlf +
       FormatDateTime( st ) + crlf + crlf +
       'Local Time is : ' + crlf +
       FormatDateTime( lt );
  // just to show datetime infos
  MsgBox( s ,mbInformation, MB_OK );
  Result := true;
end;

你可能感兴趣的:(职场,休闲,如何存储日期和注册表中安装时间)