Recent

Author Topic: [SOLVED] Get application version info  (Read 13489 times)

tk

  • Sr. Member
  • ****
  • Posts: 372
[SOLVED] Get application version info
« on: June 30, 2014, 08:07:31 pm »
Hi,
how do I obtain application version (major, minor, revision, build) in other widgetsets than Win32?

In Windows I use GetFileVersionInfo but this is win-only.

Didn't find anything usable on the forum.

Thanks
« Last Edit: July 01, 2014, 10:18:35 am by tk »

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Get application version info
« Reply #1 on: June 30, 2014, 08:20:26 pm »
It should be unit FileInfo. This worked for me on Linux:
Code: [Select]
{ TVersion }
  TVersion = class (TPersistent)
  private
    FBuild: Integer;
    FMajor: Integer;
    FMinor: Integer;
    FVersion: Integer;
  published
    property Version: Integer read FVersion write FVersion;
    property Major: Integer read FMajor write FMajor;
    property Minor: Integer read FMinor write FMinor;
    property Build: Integer read FBuild write FBuild;
  end;         

...

  aVersionInfo:=TVersionInfo.Create;
  VersionInfo:=TVersion.Create;
  try
    aVersionInfo.Load(HINSTANCE);
    VersionInfo.Version:=aVersionInfo.FixedInfo.FileVersion[0];
    VersionInfo.Major:=aVersionInfo.FixedInfo.FileVersion[1];
    VersionInfo.Minor:=aVersionInfo.FixedInfo.FileVersion[2];
    VersionInfo.Build:=aVersionInfo.FixedInfo.FileVersion[3];
  finally
    if assigned(aVersionInfo) then aVersionInfo.Free;
  end;
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

tk

  • Sr. Member
  • ****
  • Posts: 372
Re: Get application version info
« Reply #2 on: July 01, 2014, 05:47:42 am »
It should be unit FileInfo. This worked for me on Linux:

For me no unit FileInfo can be found under Linux, compiler reports error when added to uses clause.
And nor can I find any TVersionInfo class or function in Lazarus and FPC sources.
The only things I was able to find is TFileVersionInfo from FPC fcl-base directory but that is Win/WinCE only.

Zoran

  • Hero Member
  • *****
  • Posts: 1975
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Get application version info
« Reply #3 on: July 01, 2014, 06:36:26 am »
Take a look at this forum thread: http://forum.lazarus.freepascal.org/index.php/topic,12435.0.html

Just don't forget to enable version info in the first place (project->project options->version info and check "include version info in executable").
Works in Linux as well as in Windows.
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Get application version info
« Reply #4 on: July 01, 2014, 09:01:02 am »
The code in this post contains safeguards in case no version information is built into the app...

http://forum.lazarus.freepascal.org/index.php/topic,13957.msg73542.html#msg73542
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

jwdietrich

  • Hero Member
  • *****
  • Posts: 1266
    • formatio reticularis
Re: Get application version info
« Reply #5 on: July 01, 2014, 09:01:35 am »
Another solution that works very well, even on Mac OS X with Carbon widgetset, is Mike Thompson's VersionSupport unit that is available from http://forum.lazarus.freepascal.org/index.php/topic,13957.0.html.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 4.2.0 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tk

  • Sr. Member
  • ****
  • Posts: 372
Re: Get application version info
« Reply #7 on: July 01, 2014, 10:18:19 am »
Marked as solved. Thank you

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: [SOLVED] Get application version info
« Reply #8 on: July 01, 2014, 03:37:06 pm »
Quote
For me no unit FileInfo can be found under Linux, compiler reports error when added to uses clause.
Here (FPC 2.7.1) shows me unit FileInfo is in ..packages/fcl-base/src/fileinfo.pp

EDIT: FPC 2.6.4 under Wine knows the unit too (..packages/fcl-base/src/win/fileinfo.pp).
« Last Edit: July 01, 2014, 03:40:56 pm by Blaazen »
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: [SOLVED] Get application version info
« Reply #9 on: July 01, 2014, 03:40:06 pm »
Quote
For me no unit FileInfo can be found under Linux, compiler reports error when added to uses clause.
That's why there are 2 versions on the wiki page I linked - one for 2.6.x and one for trunk/2.7.1..
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018