Inno Setup:创建有效期为一年的应用程序 [英] Inno Setup: Create application valid for one year

查看:125
本文介绍了Inno Setup:创建有效期为一年的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用新代码测试软件.

const MY_EXPIRY_DATE_STR = '20131112'; //Date format: yyyymmdd

function InitializeSetup(): Boolean;
var
  ErrorCode: Integer;
begin
  //If current date exceeds MY_EXPIRY_DATE_STR then return false and exit Installer.
  result := CompareStr(GetDateTimeString('yyyymmdd', #0,#0), MY_EXPIRY_DATE_STR) <= 0;

  if not result then
    begin
    MsgBox('Now it''s forbidden to install this program', mbError, MB_OK);
end 
      if (MsgBox('Autocad will compulsory closed,so please save your drawings and then press OK', mbConfirmation, MB_OK) = IDOK) then
         begin
           ShellExec('open', 'taskkill.exe', '/f /im acad.exe','', SW_HIDE, ewNoWait, ErrorCode);
           ShellExec('open', 'tskill.exe', ' ACAD', '', SW_HIDE, ewNoWait, ErrorCode);
           Result := True;
         end
       else
         begin
           Result := False;
         end;
    end;

问题是安装程序显示错误消息(现在禁止安装此程序),但它会继续安装.我希望它退出安装程序.

The issue is the setup show the error message (Now it's forbidden to install this program) but it continue install. I want it exit the installer.

推荐答案

当您满足到期条件时,您会忘记从函数中返回.

You're forgetting to return from the function when your expiry condition is met.

  if not result then
    begin
    MsgBox('Now it''s forbidden to install this program', mbError, MB_OK);
end 

应该是:

  if not Result then
    begin
      MsgBox('Now it''s forbidden to install this program', mbError, MB_OK);
      Exit;
    end;

在没有Exit的情况下,以下语句可能会再次将Result设置为"True".

Without the Exit, the following statements execute with the possibility of setting Result to 'True' again.

还请注意格式.如果您做对了,很有可能您不会问这个问题.

Notice also the formatting. If you had it right, there is a good chance that you wouldn't be asking this question.

这篇关于Inno Setup:创建有效期为一年的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆