Inno Setup:具有不同选项的不同序列号?

Inno Setup: Different Serial keys with different options?

如何在 Inno Setup 中提供多个序列号和多个选项?

我想根据我提供给客户的不同序列密钥,在注册表中写入不同的值。

ex 不同的序列号,例如

sKey1 = "A1AA-B2ACF-HEJUI-UYTER"
sKey2 = "A1BB-B2ACF-HEJUI-UYTER"
sKey3 = "A1CC-B2ACF-HEJUI-UYTER"

要在注册表中创建的不同键的前 4 个或不同字符

if (custInput.startwith ("A1AA") then
    Root: "HKLM"; Subkey: "SOFTWARE\Version\"; ValueType:string; ValueName:"Name";ValueData: "{"Lite"}"; 
elseif  (custInput.startwith ("A1BB") then
    Root: "HKLM"; Subkey: "SOFTWARE\Version\"; ValueType:string; ValueName:"Name";ValueData: "{"Pro"}"; 
elseif  (custInput.startwith ("A1CC") then
    Root: "HKLM"; Subkey: "SOFTWARE\Version\"; ValueType:string; ValueName:"Name";ValueData: "{"Online"}"; 
endif

如何在 Inno Setup 中实现这一点?我在下面使用了 CheckSerial 函数:

function CheckSerial(Serial: String): Boolean;
  begin
    Result := Serial = '{#SerialNumber}';
  end;

使用 scripted constant 以编程方式决定要存储到注册表的值:

[Setup]
UserInfoPage=yes

[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Version"; ValueType: string; ValueName: "Name"; \
    ValueData: "{code:GetEdition}";
[Code]

var
  Serials: TStrings;
  Editions: TStrings;

function CheckSerial(Serial: String): Boolean;
begin
  Result := (Serials.IndexOf(Serial) >= 0);
end;

procedure RegisterEdition(Serial: string; Edition: string);
begin
  Serials.Add(Serial);
  Editions.Add(Edition);
end;

function GetEdition(Param: string): string;
var
  Index: Integer;
begin
  Index := Serials.IndexOf(WizardForm.UserInfoSerialEdit.Text);
  if Index >= 0 then Result := Editions[Index];
end;

function InitializeSetup(): Boolean;
begin
  Serials := TStringList.Create;
  Editions := TStringList.Create;

  RegisterEdition('A1AA-B2ACF-HEJUI-UYTER', 'Lite');
  RegisterEdition('A1BB-B2ACF-HEJUI-UYTER', 'Pro');
  RegisterEdition('A1CC-B2ACF-HEJUI-UYTER', 'Online');

  Result := True;
end;