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

**URL:** https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945
**Category:** Discussion
**Created:** [August 28, 2008, 10:28am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945 "2008-08-28T10:28:03Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 28, 2008, 10:28am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/1 "2008-08-28T10:28:03Z")

</div>

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&nbsp;&nbsp;&nbsp; FinalBuilder result  
------------------------------  
4.1.1.13&nbsp;&nbsp; 4.1.1.13  
1.0.0.9&nbsp;&nbsp;&nbsp; 1.0.009  
2.0.0.0&nbsp;&nbsp;&nbsp; 2.0.0.0  
6.0.84.18&nbsp; 6.00.8418  
6.0.81.69&nbsp; 6.00.8169  
2.1.0.651&nbsp; 2.01.0651  
1.1.0.65&nbsp;&nbsp; 1.01.0065  
1.0.0.0&nbsp;&nbsp;&nbsp; 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  
&nbsp; VerInfoBuf: Pointer;&nbsp;&nbsp;&nbsp; // points to memory storing version info  
&nbsp; VerInfoSize: Integer;&nbsp;&nbsp; // size of version info memory  
&nbsp; Dummy: Windows.THandle; // unused parameter required by API function  
&nbsp; PFFI: Pointer;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // points to fixed file info  
&nbsp; FFISize: LongWord;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // size of file file info returned from API (unused)  
begin  
&nbsp; // Assume failure: sets zero result  
&nbsp; FillChar(FFI, SizeOf(FFI), 0);  
&nbsp; Result := False;

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

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

...

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

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

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [August 29, 2008, 2:00am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/2 "2008-08-29T02:00:32Z")

</div>

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

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 29, 2008, 8:16am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/3 "2008-08-29T08:16:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [August 29, 2008, 11:03am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/4 "2008-08-29T11:03:00Z")

</div>

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](http://www.delphidabbler.com/articles.php?id=20)

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 1, 2008, 1:38am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/5 "2008-09-01T01:38:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 1, 2008, 7:37am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/6 "2008-09-01T07:37:15Z")

</div>

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.

&nbsp;

The attached project shows you the problem.

[TEST.fbp6](https://www.finalbuilder.com/forums/uploads/default/original/2X/a/a32beaee9378707ffda89e744c547ce2a0cf9631.fbp6) (25.221 KB)

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 2, 2008, 4:44am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/7 "2008-09-02T04:44:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 2, 2008, 7:23am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/8 "2008-09-02T07:23:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 3, 2008, 2:16am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/9 "2008-09-03T02:16:18Z")

</div>

of course :)  
  
please try this build:  
[https://www.finalbuilder.com/downloa...10\_961.exe](https://www.finalbuilder.com/downloads/finalbuilder/610/FB610_961.exe)

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 3, 2008, 2:40am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/10 "2008-09-03T02:40:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 4, 2008, 3:03am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/11 "2008-09-04T03:03:47Z")

</div>

thanks - fixed, new build shortly.

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 4, 2008, 5:39am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/12 "2008-09-04T05:39:16Z")

</div>

try this:  
https://www.finalbuilder.com/downloads/finalbuilder/610/FB610\_971.exe

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 4, 2008, 7:12am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/13 "2008-09-04T07:12:02Z")

</div>

I did. It is working now.:)

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

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 4, 2008, 7:45am UTC](https://www.finalbuilder.com/forums/t/extract-version-info-results-differs-the-result-generated-with-my-program/945/14 "2008-09-04T07:45:02Z")

</div>

Y.A.W.   
  
 thanks for confirming the fix.
