您的位置:首页 > 其它

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

2009-11-07 09:20 218 查看
;
; 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
'GetSystemTime@kernel32.dll';
procedure GetLocalTime(var lpSystemTime: TSystemTime); external
'GetLocalTime@kernel32.dll';
// 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;本文出自 “学无止境” 博客,请务必保留此出处http://dqk1985.blog.51cto.com/1005868/223406
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: