在运行时检查安装程序是否具有Uninstallable = True?

时间:2015-10-09 14:41:55

标签: installation installer inno-setup pascalscript delphi

我在安装后的步骤中发现了这段代码:

procedure CurStepChanged(CurStep: TSetupStep);
begin

  if CurStep = ssPostInstall then begin
    CreateSymbolicLink(ExpandConstant('{app}\Uninstall.vsf'), ExpandConstant('{cf}\Inno Setup\Carbon.vsf'), 0)
    CreateSymbolicLink(ExpandConstant('{app}\Uninstall.dll'), ExpandConstant('{cf}\Inno Setup\VclStylesinno.dll'), 0)
  end;

end;

我希望只有在安装程序有Uninstallable=True时才能创建符号链接,我怎么能从pascal脚本中删除它?

请注意,我还假装在以下情况中确定它:Uninstallable=not IsTaskSelected('task name')

1 个答案:

答案 0 :(得分:2)

使用#define存储值。您可以使用ExpandConstant在代码部分中检查它的值。

示例:

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define Uninstallable "no"

[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
Uninstallable={#Uninstallable}

[Code]  
procedure CurStepChanged(CurStep: TSetupStep);
begin    
  if CurStep = ssPostInstall then begin
    if LowerCase(ExpandConstant('{#Uninstallable}')) = 'yes' then
    begin
      CreateSymbolicLink(ExpandConstant('{app}\Uninstall.vsf'), ExpandConstant('{cf}\Inno Setup\Carbon.vsf'), 0);
      CreateSymbolicLink(ExpandConstant('{app}\Uninstall.dll'), ExpandConstant('{cf}\Inno Setup\VclStylesinno.dll'), 0);
    end;
  end;    
end;