如果某个日期过期,如何停止Inno-Setup安装程序?

如果某个日期过期,如何停止Inno-Setup安装程序?

问题描述:

请让我知道如何在安装过程中检查当前日期.

Please let me know how to check the current date during the installation.

如果当前日期(取自Windows主机)大于硬编码(嵌入)日期,我必须在安装程序脚本中嵌入某个日期,然后通知用户并停止安装过程

I have to embed a certain date in the installer script, and then notify the user and stop the installation process if current date (which is taken from Windows host) is bigger than hard-coded (embedded) date

谢谢

使用Inno内置日期例程 GetDateTimeString 的替代解决方案.

An alternative solution using Inno's built-in date routine GetDateTimeString.

[Code] 

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

function InitializeSetup(): Boolean;
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
    MsgBox('This Software is freshware and the best-before date has been exceeded. The Program will not install.', mbError, MB_OK);
end;