下次执行Inno Setup制作的安装程序时,在自定义页面上恢复先前输入的数据 [英] Restore previously entered data on custom page next time Inno Setup-made installer is executed

查看:76
本文介绍了下次执行Inno Setup制作的安装程序时,在自定义页面上恢复先前输入的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用此代码,但是我需要卸载部分代码:在下次打开可执行文件时,它可以读取在服务名称"字段中写入的信息.

I want to use this code, but the part of the code to uninstall I need: in the next time I open the executable it can read the information written in this field 'Service name'.

能帮帮我吗?

甚至现在它还在哪里存储以服务名称"书写的信息?

And even now where it stores this information written in the 'Service name'?

相关:
如何在安装过程中记录用户输入,以便可以在卸载期间使用?

推荐答案

如果我对您的理解正确,那么您正在寻找一种使用先前存储的数据填充输入字段的方法.在您链接的示例中,您会注意到使用了 GetPreviousData 函数,该函数仅用于读取先前由 SetPreviousData存储的数据函数调用.

If I understand you correctly, you're looking for a way to fill an input field with the previously stored data. In the example that you linked you can notice that there is used the GetPreviousData function which is used just for reading data previously stored by the SetPreviousData function call.

原理是,当 RegisterPreviousData 事件触发时,您调用 SetPreviousData 函数您要存储的每个值,并为每个值提供一些唯一的键(此函数的参数称为ValueName,这并不是很容易理解的).例如,这里是如何存储来自两个不同输入字段的值:

The principle is, that when the RegisterPreviousData event fires, you call the SetPreviousData function for each value that you want to store, providing for each value some unique key (parameter of this function is called ValueName which is not much self-explaining). For example here is how to store values from two different input fields:

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  SetPreviousData(PreviousDataKey, 'MyUniqueKey1', InputPage.Values[0]);
  SetPreviousData(PreviousDataKey, 'MyUniqueKey2', InputPage.Values[1]);
end;

正如我已经提到的那样,您可以使用 GetPreviousData 函数,您可以在添加输入字段后立即调用.在此函数中,您将传递与用于存储数据的键相同的键,除了还将传递默认值(当找不到给定键的数据时将返回默认值).对于上面的代码示例,它可以像这样:

As I already mentioned, data stored this way you can read by using GetPreviousData function which you can call right after you add your input fields. Into this function you'll pass the same key as you used to store the data and except that you'll pass also the default value, which will be returned when the data for the given key won't be found. For the above code example it can be like this:

procedure InitializeWizard;
var
  Index: Integer;
begin
  InputPage := CreateInputQueryPage(wpWelcome, 'Caption', 'Description', '');

  Index := InputPage.Add('Input field 1:', False);
  InputPage.Values[Index] := GetPreviousData('MyUniqueKey1', 'Default value');

  Index := InputPage.Add('Input field 2:', False);
  InputPage.Values[Index] := GetPreviousData('MyUniqueKey2', 'Default value');
end;

此机制将注册表用作值的存储.更具体地说,它与存储卸载信息的密钥相同.实际上, RegisterPreviousDataPreviousDataKey参数传递的内容> 事件方法是刚刚创建的卸载数据注册表项的句柄,用于告诉 SetPreviousData 函数将数据存储在何处.

This mechanism uses registry as a storage for values. To be more specific, it is the same key as where the uninstallation information are stored. Actually, what is passed by PreviousDataKey parameter of the RegisterPreviousData event method is a handle to the just created uninstallation data registry key, which is used to tell the SetPreviousData function where to store the data.

值键由固定的Inno Setup CodeFile:前缀部分组成,后跟

Value keys in that registry key path are composed from the fixed Inno Setup CodeFile: prefix part followed by the unique key passed in the SetPreviousData function. So, for our example would Inno Setup create the following value keys in uninstallation data registry key path:

Inno Setup CodeFile: MyUniqueKey1
Inno Setup CodeFile: MyUniqueKey2

这篇关于下次执行Inno Setup制作的安装程序时,在自定义页面上恢复先前输入的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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