TApplication.Version ??? lazarus / 8-Other ---------------------------------------------------------------------- DelphiFreak · 2008-06-13 14:42 Dear Lazarus NG, in my applications I always show the version number in the caption of the main file. In Delphi I used the following code to read the version information from the exe/dll-file. Code: [Select]function GetVersion(_filename:string=''): String; var   VerInfoSize: DWord;   VerInfo: Pointer;   VerValueSize: DWord;   VerValue: PVSFixedFileInfo;   Dummy: DWord; begin   Result:='';   if _filename='' then _filename:=ParamStr(0);   VerInfoSize := GetFileVersionInfoSize(PChar(_filename), Dummy);   if VerInfoSize=0 then exit;   GetMem(VerInfo, VerInfoSize);   GetFileVersionInfo(PChar(_filename), 0, VerInfoSize, VerInfo);   VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);   with VerValue^ do   begin     result := IntTostr(dwFileVersionMS shr 16);     result := result+'.'+   IntTostr(dwFileVersionMS and $FFFF);     result := result+'.'+   IntTostr(dwFileVersionLS shr 16);     result := result+'.'+   IntTostr(dwFileVersionLS and $FFFF);   end;   FreeMem(VerInfo, VerInfoSize); end; Now I would like to improve TApplication with a property "Version". The problem: My code is only working for windows plattforms. Does someone know a better method to retrieve the version information ? Regards, Sam ---------------------------------------------------------------------- Phil · 2008-06-13 17:27 Quote from: "DelphiFreak" Now I would like to improve TApplication with a property "Version". The problem: My code is only working for windows plattforms. Does someone know a better method to retrieve the version information ? What I do on non-Windows platforms is simply to create a myapp.version file and include this with the executable. This file is in INI format that can be loaded in one line of code with TIniFile.Create. Example: [Version Info Keys] FileDescription=My application file To retrieve FileDescription in your code: IniFile.ReadString('Version Info Keys', 'FileDescription', ''); Thanks. -Phil ---------------------------------------------------------------------- DelphiFreak · 2008-06-17 16:04 Would it be a good idea to straight use the .lpi file which contains the version info already ? What do you think ? ---------------------------------------------------------------------- Phil · 2008-06-17 17:18 Quote from: "DelphiFreak"Would it be a good idea to straight use the .lpi file which contains the version info already ? What do you think ? I don't think you would want to distribute the .lpi file with your app, but you could certainly extract the information you need to create the .version file from the .lpi file. I haven't used the IDE's version facility because it's so limited (and for a while was buggy). For example, there's really no limit on what kind of version information you might want to store and Delphi lets you define your own version info keys. Similarly, there's no limit on what you can put in a Windows .rc file. However, the Lazarus IDE only supports a fixed set of standard version info keys. This is too limiting for me so I don't use it at all. A good idea to add to the IDE, but not followed though all the way. Thanks. -Phil