加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

常量 – 在Inno Setup中安装之前使用[Code]更改AppID

发布时间:2020-12-15 09:36:46 所属栏目:大数据 来源:网络整理
导读:在设置中,我为用户提供了使用单选按钮安装32位或64位版本的选项. 然后,我想将“_32”或“_64”附加到AppID. 我知道我可以使用脚本常量更改AppID,但在安装程序启动时会调用所需的函数.但此时单选按钮尚不存在,因此我收到错误“无法调用proc”. 我咨询了Inno S
在设置中,我为用户提供了使用单选按钮安装32位或64位版本的选项.

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

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

我咨询了Inno Setup帮助,我读到你可以在insatllation过程开始之前的任何给定点更改AppID(如果我没有正确使用).

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

我期待着你的回答!

解决方法

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

[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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读