gpt4 book ai didi

constants - 在 Inno Setup 安装之前使用 [Code] 更改 AppID

转载 作者:行者123 更新时间:2023-12-04 23:04:27 24 4
gpt4 key购买 nike

在设置中,我为用户提供了使用单选按钮安装 32 位或 64 位版本的选项。

然后我想将“_32”或“_64”附加到 AppID。

我知道我可以使用脚本常量更改 AppID,但是在安装程序启动时会调用所需的函数。但此时单选按钮尚不存在,因此我收到错误“无法调用 proc”。

我咨询了 Inno Setup 帮助,我了解到您可以在安装过程开始之前的任何给定点更改 AppID(如果我理解正确的话)。

那么我该如何做到这一点呢?

我期待你的回答!

最佳答案

部分{code:...}某些指令值的函数被多次调用,AppId是其中之一。更具体地说,它被调用了两次。一次是在创建向导表单之前,一次是在安装开始之前。您可以做的只是检查您尝试从中获取值的复选框是否存在。您可以简单地询问它是否是 Assigned如下:

[Setup]
AppId={code:GetAppID}
...

[Code]
var
Ver32RadioButton: TNewRadioButton;
Ver64RadioButton: TNewRadioButton;

function GetAppID(const Value: string): string;
var
AppID: string;
begin
// check by using Assigned function, if the component you're trying to get a
// value from exists; the Assigned will return False for the first time when
// the GetAppID function will be called since even WizardForm not yet exists
if Assigned(Ver32RadioButton) then
begin
AppID := 'FDFD4A34-4A4C-4795-9B0E-04E5AB0C374D';
if Ver32RadioButton.Checked then
Result := AppID + '_32'
else
Result := AppID + '_64';
end;
end;

procedure InitializeWizard;
var
VerPage: TWizardPage;
begin
VerPage := CreateCustomPage(wpWelcome, 'Caption', 'Description');
Ver32RadioButton := TNewRadioButton.Create(WizardForm);
Ver32RadioButton.Parent := VerPage.Surface;
Ver32RadioButton.Checked := True;
Ver32RadioButton.Caption := 'Install 32-bit version';
Ver64RadioButton := TNewRadioButton.Create(WizardForm);
Ver64RadioButton.Parent := VerPage.Surface;
Ver64RadioButton.Top := Ver32RadioButton.Top + Ver32RadioButton.Height + 4;
Ver64RadioButton.Caption := 'Install 64-bit version';
end;

关于constants - 在 Inno Setup 安装之前使用 [Code] 更改 AppID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16004473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com