title: Inno Setup: how to call custom functions from the InstallDelete section
body: <p>I would need Inno Setup generated installer to delete certain files prior installation if the software is already installed with an older version.</p>
  
  <p>I tried to do this by comparing version numbers (custom function below) but when compiling, Inno Setup generates an error: </p>
  
  <blockquote>
    <p>[ISPP] Undeclared identifier: "GetInstalledVersion".</p>
  </blockquote>
  
  <p>The Inno Setup script relevant extract is:</p>
  
  <pre><code>(...)
  [Code]
  function GetInstalledVersion(MandatoryButNotUsedParam: String): String;
  var Version: String;
  begin
    if RegValueExists(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\'+ExpandConstant('AppId')+'_is1', 'DisplayVersion') then
      begin
        RegQueryStringValue(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\Uninstall\'+ExpandConstant('AppId')+'_is1', 'DisplayVersion', Version);
        MsgBox(ExpandConstant('Existing version:'+Version+'  New version:'+ExpandConstant('AppVersion')), mbInformation, MB_OK);
        Result := Version;
      end
    else
      begin
        Result := '';
      end
  end;
  (...)
  [InstallDelete]
  #define InstalledAppVersion GetInstalledVersion('')
  #if "1.013" &gt; InstalledAppVersion
    Type: files; Name: {userappdata}\xxx\*.hhd
  #endif
  </code></pre>
  
  <p>Being new to Inno Setup, this is certainly a trivial question but no answer found on forums. The question is thus: how can I properly call the function <code>GetInstalledVersion</code> from the <code>[InstallDelete]</code> section?</p>
  
  <p>Is there an issue because <code>[InstallDelete]</code> section might be called before <code>[code]</code> section is read?</p>
  
  <p>Many thanks for any help / hint!</p>