Restore previously entered data on custom page next time Inno Setup-made installer is executed

丶灬走出姿态 提交于 2020-01-11 04:09:12

问题


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'.

Can help me?

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

Relaced to:
How do I record user input during install, so it can be used during uninstall?


回答1:


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.

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;

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;

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.

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


来源:https://stackoverflow.com/questions/25275892/restore-previously-entered-data-on-custom-page-next-time-inno-setup-made-install

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