Search code examples
inno-setuppascalscript

How can I use multiple Check functions in the [Registry] section?


Sample:

Root: "HKLM64"; Subkey: "Software\Community Talks\Public Talks\Preferences"; \
  ValueType: dword; ValueName: "ReuseCong"; ValueData: "{code:ReuseCongregation}"; \
  Flags: uninsdeletevalue; Check: IsNewInstall IsWin64
Root: "HKLM64"; Subkey: "Software\Community Talks\Public Talks\Preferences"; \
  ValueType: dword; ValueName: "Duplicate"; ValueData: "{code:Duplicate}"; \
  Flags: uninsdeletevalue; Check: IsNewInstall IsWin64
Root: "HKLM64"; Subkey: "Software\Community Talks\Public Talks\Preferences"; \
  ValueType: dword; ValueName: "Language"; ValueData: "{code:DatabaseLanguage}"; \
  Flags: uninsdeletevalue; Check: IsNewInstall IsWin64

Will not compile:

Error on line 406 in setup.iss: Directive or parameter "Check" expression error: Invalid token 'IsWin64' found.


I can't change the IsNewInstall function:

// Returns True if we are performing a new install
function IsNewInstall(): Boolean;
begin
  // Make sure IsUpgrading has already beed called.
  result := not bIsUpgrading;
end;

But I include it if it helps.


Solution

  • The Check parameter supports simple boolean operators like or or and. Examples are given at the end of Components and Tasks Parameters documentation.

    You want and here, I assume:

    Check: IsNewInstall and IsWin64
    

    Alternatively, particularly if the expression gets too complicated or when it is used frequently, you can factor it out to a separate function:

    function IsNewInstallOnWin64: Boolean;
    begin
      Result := IsNewInstall and IsWin64;
    end;