我正在尝试让以下 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/