您的位置:首页 > 其它

如何设置安装程序的日期时间限制

2009-11-07 09:20 477 查看
;
[Setup]
AppName=DateTimeStop
AppVerName=DateTimeStop
Uninstallable=false
UpdateUninstallLogAppName=false
DisableDirPage=true
DisableProgramGroupPage=true
DefaultDirName={pf}\DateTimeStop
DisableStartupPrompt=true
[_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 GetLocalTime(var lpSystemTime: TSystemTime); external
'GetLocalTime@kernel32.dll';
//
// compare dt1 and dt2, return false id dt1 is lower than dt2
// thanks to Bruno Gellweiler that provide a working function :)

function IsOKDateTime( dt1, dt2: TSystemTime ) : Boolean;
begin
Result := true;
if dt2.wYear < dt1.wYear then
result := false
else if dt2.wYear = dt1.wYear then
if dt2.wMonth < dt1.wMonth then
result := false
else if dt2.wMonth = dt1.wMonth then
if dt2.wDay < dt1.wDay then
result := false ;
end;

function InitializeSetup: Boolean;
var
lt, datelimit: TSystemTime;
s, crlf: string;
begin
crlf := #13#10;
// let's say it is not allowed to install after 1 May 2003
datelimit.wYear := 2003;
datelimit.wMonth := 5;
datelimit.wDay := 1;
GetLocalTime(lt);
Result := IsOKDateTime( lt, datelimit );
s := 'Install time limit, it is not possible to install this program.';
if not Result then
// just to show datetime infos
MsgBox( s , mbError, MB_OK );
end;本文出自 “学无止境” 博客,请务必保留此出处http://dqk1985.blog.51cto.com/1005868/223407
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: