Inno Setup 将用户输入从安装后的自定义页面保存到注册表?

Inno Setup save user inputs from an after-installation custom page to registry?

与此问题相关:

执行此操作时:

[Code]

var
  UserInputsPage: TInputQueryWizardPage;

function GetUserName(Param: string): string;
begin
  Result := UserInputsPage.Values[0];
end;

function GetUserBirthday(Param: string): string;
begin
  Result := UserInputsPage.Values[1];
end;

procedure InitializeWizard;
begin
  { Create the page }
  UserInputsPage :=
    CreateInputQueryPage(wpWelcome,
      'User information', 'User name and birthday',
      'Please specify the following information, then click Next.');
  UserInputsPage.Add('Name:', False);
  UserInputsPage.Add('Birthday:', False);
end;

[Registry]
Root: HKCU; Subkey: "Software\My Company\My Program"; \
    ValueType: string; ValueName: "UserName"; ValueData: "{code:GetUserName}"
Root: HKCU; Subkey: "Software\My Company\My Program"; \
    ValueType: string; ValueName: "UserBirthday"; ValueData: "{code:GetUserBirthday}"

用户输入已写入注册表。

当我改变

CreateInputQueryPage(wpWelcome,

CreateInputQueryPage(wpInstalling,

所以我有:

var
  UserInputsPage: TInputQueryWizardPage;

function GetUserName(Param: string): string;
begin
  Result := UserInputsPage.Values[0];
end;

function GetUserBirthday(Param: string): string;
begin
  Result := UserInputsPage.Values[1];
end;

procedure InitializeWizard;
begin
  { Create the page }
  UserInputsPage :=
    CreateInputQueryPage(wpInstalling,
      'User information', 'User name and birthday',
      'Please specify the following information, then click Next.');
  UserInputsPage.Add('Name:', False);
  UserInputsPage.Add('Birthday:', False);
end;

[Registry]
Root: HKCU; Subkey: "Software\My Company\My Program"; \
    ValueType: string; ValueName: "UserName"; ValueData: "{code:GetUserName}"
Root: HKCU; Subkey: "Software\My Company\My Program"; \
    ValueType: string; ValueName: "UserBirthday"; ValueData: "{code:GetUserBirthday}"

用户输入未写入注册表。

有人能告诉我为什么吗?

好吧,答案很明显,安装后

显示带有 AfterID = wpInstalling 的自定义页面

所以注册表项是在用户有机会输入它们的值之前创建的。

必须在安装前提供安装所需的所有信息

将您的自定义页面移到更早的位置。


或者,如果您需要保留页面,它所在的位置,您需要使用 RegWriteStringValue function.

以编程方式编写密钥

有关示例,请参阅 How to write install path to registry after install is complete with Inno Setup