首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Inno Setup中安装之前,使用[代码]更改AppID

问在Inno Setup中安装之前,使用[代码]更改AppID
EN

Stack Overflow用户
提问于 2013-04-15 05:23:04
回答 1查看 3.1K关注 0票数 5

在设置中,我让用户使用单选按钮选择安装32位或64位版本。

然后,我想将'_32‘或'_64’附加到AppID。

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

我查阅了Inno Setup帮助,我读到您可以在insatllation过程开始之前的任何给定时刻更改AppID (如果我理解正确的话)。

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

我期待着你的回答!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-15 08:12:23

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

代码语言:javascript
复制
[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;
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16004473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档