In Inno Setup how to save user inputs to registry?

感情迁移 提交于 2019-12-08 00:49:37

问题


This is what I'm trying to figure out, in Inno Setup I want the installer to get

  1. User's name (manual input)
  2. Birthday (manual input)

And both of those i want to use as variable to save it in registry


回答1:


Just combine answers to these questions:

  • Adding user completed form to Inno Setup
  • Inno Setup [Registry] - Using function return value or Inno Setup: How to pass variable from [Code] to [Run]

They show you how to use the CreateInputQueryPage function and scripted constants to get a code like this:

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

This will create a registry key like:

[HKEY_CURRENT_USER\SOFTWARE\My Company\My Program]
"UserName"="John Doe"
"UserBirthday"="1975-05-02"


来源:https://stackoverflow.com/questions/42989109/in-inno-setup-how-to-save-user-inputs-to-registry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!