windows - 使用 Inno Setup 将序列号写入文件

标签 windows installation inno-setup pascalscript

我正在尝试让以下 Inno Setup 代码工作:

[Setup]
UserInfoPage=yes

[Code]
function CheckSerial(Serial: String): Boolean;
begin
  Result := true;
  SaveStringToFile('c:\Registration.txt', Serial, False);
end;

当在 UserInfoPage 中知道文件路径时,代码非常简单。然而,当我需要在我的应用程序旁边写这个文件时,它变得异常复杂。两者都不是:

WizardDirValue();

也不

ExpandConstant('{app}');

工作。第一个在过早调用时是空的,第二个甚至没有运行,我得到:

Internal error: an attempt was made to expand the "app" constant before it was initialized.

如何将 Serial 值存储到需要驻留在应用程序旁边的文件(.exe 文件)中?

最佳答案

您可以展开 {userinfoserial}在选择应用程序目录后触发的某些事件中获取用户在信息页面中输入的序列号的常量,例如:

[Setup]
AppName=My Program
AppVersion=1.5
UserInfoPage=yes
DefaultDirName={pf}\My Program
[Code]
function CheckSerial(Serial: String): Boolean;
begin
  Result := True;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall then
  begin
    SaveStringToFile(ExpandConstant('{app}\Serial.txt'),
      ExpandConstant('{userinfoserial}'), False);
  end;
end;

关于windows - 使用 Inno Setup 将序列号写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25870729/

相关文章:

linux - 以静默模式安装 Oracle 后,我无法运行 SQLPLUS

ruby-on-rails - 为什么 bundle install 不允许 pg gem 完全安装?

windows - WinHttpRequest.5.1 是适用于 Windows 11 的良好 API 还是需要 Iexplorer?

使用 Inno Setup 安装时,Python/Qt/SQLite3 应用程序不运行

c# - CryptoAPITransform 使用正确吗?内存泄漏

java - 如何创建 RTSP 服务器以从网络摄像头进行流传输?

c - 进程 Hook 问题

python - 安装了 Anaconda 4.3.1(64 位),其中包含 Python 3.6 但缺少 pip3,无法安装 tensorflow

debian - 在 Debian Jessie 上进行无人值守的 Percona Server 5.7 安装

windows - dpinst 无法静默安装驱动程序