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?
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:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[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;