Forum > General

[resolved] How to read out the version info set in the Project options

(1/1)

Muso:
I want to read out the version info I set in the project Option. I found this recipe:
https://wiki.freepascal.org/Show_Application_Title,_Version,_and_Company#FPC_3.0.2B
This does however not work:
*
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---FileVerInfo:=TFileVersionInfo.Create(nil); has to be
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---FileVerInfo:=TFileVersionInfo.Create;
*
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---FileVerInfo.ReadFileInfo;does not exist.

How to I cane to load the version info into a TFileVersionInfo?Can anybody update the Wiki page to the current status of FPC 3.2?

I use:
Lazarus 2.2.0 (rev lazarus_2_2_0) FPC 3.2.2 x86_64-win64-win32/win64

wp:
I tested the following code with laz2.2.0-fpc3.2.2/64bit on Win 11, and it compiles and runs without any issue:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  fileinfo; procedure TForm1.Button1Click(Sender: TObject);var  FileVerInfo: TFileVersionInfo;  s: String;begin  FileVerInfo := TFileVersionInfo.Create(nil);  try    FileVerInfo.ReadFileInfo;    s := 'Company: ' + FileVerInfo.VersionStrings.Values['CompanyName'] + LineEnding +         'File description: ' + FileVerInfo.VersionStrings.Values['FileDescription'] + lineEnding +         'File version: ' + FileVerInfo.VersionStrings.Values['FileVersion'] + LineEnding +         'Internal name: ' +FileVerInfo.VersionStrings.Values['InternalName'] + LineEnding +         'Legal copyright: ' + FileVerInfo.VersionStrings.Values['LegalCopyright'] + LineEnding +         'Original filename: ' + FileVerInfo.VersionStrings.Values['OriginalFilename'] + LineEnding +         'Product name: ' + FileVerInfo.VersionStrings.Values['ProductName'] + LineEnding +         'Product version: ' + FileVerInfo.VersionStrings.Values['ProductVersion'];    ShowMessage(s);  finally    FileVerInfo.Free;  end; end;

bobby100:
TVersionInfo from ( \lazarus\lcl\interfaces\mui\vinfo.pas ) works fine if you need just the version (build).


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  Info: TVersionInfo;begin  Info := TVersionInfo.Create;  Info.Load(HINSTANCE);  // get just the Build Number  StatusBar1.Panels[0].Text :=    IntToStr(Info.FixedInfo.FileVersion[0]) + '.' +    IntToStr(Info.FixedInfo.FileVersion[1]) + '.' +    IntToStr(Info.FixedInfo.FileVersion[2]) + '.' +    IntToStr(Info.FixedInfo.FileVersion[3]);  Info.Free;end;

Muso:

--- Quote from: wp on May 19, 2022, 06:23:34 pm ---I tested the following code with laz2.2.0-fpc3.2.2/64bit on Win 11, and it compiles and runs without any issue:

--- End quote ---
Thanks.This is what I had. I see now that this code worked fine in another program of mine. I found now out the reason it failed for me was that i load other units like versiontypes, versionresource from my previous attempts to get it to work. i removed them et voilá, everything works as described in the Wiki.

Navigation

[0] Message Index

Go to full version