【发布时间】:2019-01-03 14:33:04
【问题描述】:
我正在使用Inno Setup 编译器为我的软件创建安装程序。安装程序会在首次安装期间向 Windows 注册表添加时间戳。重新安装软件时,它会检查 Windows 注册表中保存的时间戳,如果距当前日期超过 90 天,是否应该停止安装?所以我强迫用户只使用该软件 90 天。
我正在尝试将 90 天添加到当前日期时间以进行比较。在数据类型TSystemTime 中没有执行此操作的选项。我可以将天数添加到 TDateTime 变量,但我不能在 Inno Setup 脚本中使用该变量。
这是我的代码
function InitializeSetup(): Boolean;
var
InstallDatetime: string;
begin
if RegQueryStringValue(HKLM, 'Software\Company\Player\Settings', 'DateTimeInstall', InstallDatetime) then
{ I want to add 90 days before comparison }
Result := CompareStr(GetDateTimeString('yyyymmdd', #0,#0), InstallDatetime) <= 0;
if not result then
MsgBox('This Software trial period is over. The Program will not install.', mbError, MB_OK);
Result := True;
end;
我在 Stack Overflow 上看到过类似的 example。他们使用一个常数来比较日期时间。相反,我将 90 天添加到我保存的安装日期时间。
任何帮助将不胜感激。
【问题讨论】: