将变量值从安装程序传送到卸载程序
Carry variable values from installer to uninstaller
Inno Setup 安装程序中的变量值是否会转移到卸载程序中?
例如,我需要创建帐户,并在安装程序中指定用户名,并且在卸载时,使用安装程序中指定的名称访问帐户。价值是否可以延续,或者我应该将其存储在注册表之类的地方?
不,他们不是。我个人会这样做(它使用在注册表中存储自定义值的机制):
[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;
Inno Setup 安装程序中的变量值是否会转移到卸载程序中? 例如,我需要创建帐户,并在安装程序中指定用户名,并且在卸载时,使用安装程序中指定的名称访问帐户。价值是否可以延续,或者我应该将其存储在注册表之类的地方?
不,他们不是。我个人会这样做(它使用在注册表中存储自定义值的机制):
[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;