Search code examples
installationinno-setuppascalscriptfileversioninfo

How to get versions of files (exe's and dll's) which are included to Inno Setup installer exe file?


As in topic, is it possible? And, I want to display them on one page of installer if parameter (e.g. parameter passed to exe file) is set to true.

I know how to display some page:

if dev then
    PageWersjePlikow :=
        CreateOutputMsgMemoPage(
            1, 'Wersje plików zawarte w     instalatorze',
            'Lista plików niewidoczna dla klienta',
            'Pliki:', 'TU WPISAĆ WERSJE PLIKÓW');

I have some ideas, but every idea is based on .txt file built while compiling exe installer and then read from it...


Solution

  • Use GetVersionNumbers or GetVersionNumbersString support functions.

    The GetVersionNumbersString returns version in format Major.Minor.Rev.Build.

    If you need a different format, you need to use GetVersionNumbers and format the version components, the way you need (like Major.Minor.Rev):

    function MyGetVersionNumbersString(
      const Filename: String; var Version: String): Boolean;
    var
      MS, LS: Cardinal;
      Major, Minor, Rev, Build: Cardinal;
    begin
      Result := GetVersionNumbers(Filename, MS, LS);
    
      if Result then
      begin
        Major := MS shr 16;
        Minor := MS and $FFFF;
        Rev := LS shr 16;
        Build := LS and $FFFF;
        Version := Format('%d.%d.%d', [Major, Minor, Rev]);
      end
    end;