Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

inno-setup

During setup I record input from the user such as the name of the Windows service that is being created. When uninstalling this service I need to know what was originally entered as service name by the user.

What is the best way to get the service name during uninstall?

like image 471
gyurisc Avatar asked Sep 02 '25 18:09

gyurisc


1 Answers

The best fitting to your requirement seems to be to handle the RegisterPreviousData event method and from inside it call the SetPreviousData function, in which you can store a string value under your custom key. To restore the previously stored data you can call GetPreviousData function.

Here is a simple example of the usage:

[Code]
var
  UserPage: TInputQueryWizardPage;

procedure InitializeWizard;
begin
  UserPage := CreateInputQueryPage(wpWelcome, 'Caption', 'Description', '');
  UserPage.Add('Service name:', False);
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  SetPreviousData(PreviousDataKey, 'ServiceName', UserPage.Values[0]);
end;

function InitializeUninstall: Boolean;
var
  ServiceName: string;
begin
  ServiceName := GetPreviousData('ServiceName', '');
  if ServiceName <> '' then
    MsgBox('The value entered before: ' + ServiceName, mbInformation, MB_OK);
end;
like image 59
TLama Avatar answered Sep 06 '25 01:09

TLama