Related to this question: In Inno Setup how to save user inputs to registry?
When doing this:
[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}"
the user input is written to registry.
When I change
CreateInputQueryPage(wpWelcome,
to
CreateInputQueryPage(wpInstalling,
so I have:
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}"
user input is not written to registry.
Could someone please tell why?
Well, the answer is obvious, a custom page with AfterID = wpInstalling
is shown after installation.
So the registry keys are created before user has a chance to enter their value.
All information that is needed for installation has to be provided before installation.
Move your custom page earlier.
Or if you need to keep the page, where it is, you need to write the keys programaticaly using RegWriteStringValue
function.
For an example, see How to write install path to registry after install is complete with Inno Setup.