Extract version info - results differs the result generated with my program

After installing our SW we run a small program that compares properties of the installed files (size, file version, MD5 chacksum) to show the customers that the installation is correct.

I use the "extract version info" to get the file version (I tried both "FileVersion" and "File Version"). The string I get from this action is not the same as the string I generate with the test program (written in Delphi7, see the code below).

My code    FinalBuilder result
------------------------------
4.1.1.13   4.1.1.13
1.0.0.9    1.0.009
2.0.0.0    2.0.0.0
6.0.84.18  6.00.8418
6.0.81.69  6.00.8169
2.1.0.651  2.01.0651
1.1.0.65   1.01.0065
1.0.0.0    1.00

The table shows that the values are the same, but that the formattting (commas and leading zeroes) is different. My code is:

function GetFixedFileVerInfo(const FileName: string; out FFI: Windows.TVSFixedFileInfo): Boolean;
var
  VerInfoBuf: Pointer;    // points to memory storing version info
  VerInfoSize: Integer;   // size of version info memory
  Dummy: Windows.THandle; // unused parameter required by API function
  PFFI: Pointer;          // points to fixed file info
  FFISize: LongWord;      // size of file file info returned from API (unused)
begin
  // Assume failure: sets zero result
  FillChar(FFI, SizeOf(FFI), 0);
  Result := False;

  // Get size of version info: there is none if this is zero
  VerInfoSize := Windows.GetFileVersionInfoSize(PChar(FileName), Dummy);

  if VerInfoSize > 0 then
  begin
    // Allocate memory to store ver info
    GetMem(VerInfoBuf, VerInfoSize);
    try
      // Get the version info, filling buffer
      if Windows.GetFileVersionInfo(PChar(FileName), Dummy, VerInfoSize, VerInfoBuf) then
      begin
        // Get a pointer to fixed file info
        if Windows.VerQueryValue(VerInfoBuf, '\', PFFI, FFISize) then
        begin
          // Got pointer OK: record file version
          FFI := Windows.PVSFixedFileInfo(PFFI)^;
          Result := True;
        end;
      end;
    finally
      // Dispose of ver info storage
      FreeMem(VerInfoBuf, VerInfoSize);
    end;
  end;
end;

...

        if GetFixedFileVerInfo(FullFileName, FFI) then
        begin
          ActualVersion := Format('%d.%d.%d.%d', [HiWord(FFI.dwFileVersionMS),
                                                  LoWord(FFI.dwFileVersionMS),
                                                  HiWord(FFI.dwFileVersionLS),
                                                  LoWord(FFI.dwFileVersionLS)]);
        end;
...

My question now is how should I modify my code to get the same formatting as the FinalBuilder action.

How do the results compare to how Windows displays the version information? (Properties on the file, Version tab)

Thanks for your quick response. I checked my code and my FinalBuilder script again.
My Delphi code is correct, but my FinalBuilderScript was not. I used the property “FileVersion”, where I should have used the property “File Version”. I missed the space.

My previous reaction was too quick. I did some further analysis:

The version tab of the MS-Windows File Properties window shows two version numbers. The one at the top (always visible) is the value I get with my code. The value in the list is the value the FinalBuilder code extracts from the file.

I could not find a FinalBuilder action to extract the first file version string from the file. Is this possible or not?

Note:

I found an article with example code showing how to extract the file version reported by the FinalBuilder action from an executable at

http://www.delphidabbler.com/articles.php?id=20

Have you had a look at the “Extract Version Info” action? Does that work if you specify “File Version”?

I did try. The result is always an empty string. I wanted to be sure it is not a problem with oour executables. Therefore I tested my FinalBuilder script on MS-Windows executables.

I use FinalBuilder 6.1.0.935

I use Windows XP Professional SP2.

 

The attached project shows you the problem.

TEST.fbp6 (25.221 KB)

Thanks. Looking into it now. From what I can determine so far, some information is in a fixed record (like File Version) whereas other stuff is stored differently which requires the VerQueryValue to be called. FinalBuilder just uses the VerQueryValue and doesn’t look in the tagVS_FIXEDFILEINFO packed record (yet…).

“(yet…)” means that I can expect a new build soon? That would be great.

of course :)

please try this build:
https://www.finalbuilder.com/downloa...10_961.exe

Hi Tate,

I installed the new build. The good news is that I now can get both version strings from my executables. The bad news is that files not containing version information (all non-executables and some very old executables I use) now generate the following error :

GetFileVersionStrings failed
Access violation at address 77C0155D in module 'version.dll'. Read of address 00000004
Getting file version information failed

Of course I can work around the problem by making different file sets, but it would be nice if you could also fix this last error.

thanks - fixed, new build shortly.

try this:
https://www.finalbuilder.com/downloads/finalbuilder/610/FB610_971.exe

I did. It is working now.:)

Many thanks for your very fast support in fixing this problem.

Y.A.W.

thanks for confirming the fix.