lentinant
lentinant

Reputation: 832

Carry variable values from installer to uninstaller

Are values of variables in Inno Setup installer carried over to uninstaller? For example, i need to create account, and spectify user name in installer, and while uninstalling, access account using name, specified in installer. Does value carry over, or i should store it somewhere like registry?

Upvotes: 1

Views: 245

Answers (1)

TLama
TLama

Reputation: 76693

No, they are not. I would do it like this personally (it uses the mechanism for storing custom values in registry):

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  // this will store the value under the specified key; except uninstaller you
  // can read the values stored this way in installer
  SetPreviousData(PreviousDataKey, 'ValueName', 'ValueData');
end;

function InitializeUninstall: Boolean;
var
  StoredValue: string;
begin
  Result := True;
  // read the value of the given key
  StoredValue := GetPreviousData('ValueName', 'DefaultValueData');
  MsgBox(StoredValue, mbInformation, MB_OK);
end;

Upvotes: 1

Related Questions