在Inno Setup中,如何将用户输入保存到注册表? [英] In Inno Setup how to save user inputs to registry?

查看:202
本文介绍了在Inno Setup中,如何将用户输入保存到注册表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我要解决的问题,在Inno Setup中,我希望安装程序获得

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

  1. 用户名(手动输入)
  2. 生日(手动输入)

这两个我都想用作变量将其保存在注册表中

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

推荐答案

只需合并以下问题的答案即可:

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]

它们向您展示如何使用 CreateInputQueryPage函数和<一个href ="https://jrsoftware.org/ishelp/index.php?topic=scriptconstants" rel ="nofollow noreferrer">脚本常量,以获取如下代码:

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"

这篇关于在Inno Setup中,如何将用户输入保存到注册表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆