4

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...

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
vBB
  • 215
  • 1
  • 3
  • 7

2 Answers2

6

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
0

Thank you! I have found solution for checking cmd parameter:

function GetParam: Boolean;
var
   param: string;
   i: integer;
begin
   Result := False;
   for i:= 0 to ParamCount do
   begin   
      param := ParamStr(i);
      if (param = '-p') then
      begin
         Result := True;
         break;
      end;      
   end;   
end; 

With my function I can just run my installer with '-p' parameter and it will show my page containing information which I want :-)

vBB
  • 215
  • 1
  • 3
  • 7
  • 1
    You don't need to check `ParamStr(0)` because there is the full path to the application. Also, there is no need for that `param` variable if it's used only once. And it's better to `Exit` from the function rather than just `Break` the loop (it better explains the intent). And finally, using the name `GetParam` for the function that checks (case sensitively) whether the `-p` command line argument was passed is just wrong. – TLama Apr 10 '15 at 09:02