There is nothing wrong with your television set. Do not attempt to adjust the picture.
The VersionInfo library basically just wraps the Win32 GetFileVersionInfo
(and related) API functions. The library makes it very easy to read values from the Version Info resource of Windows executables and DLLs.
TApplication
class with a version info property.
The TApplicationVersion
class contains the core functionality of the library. The following is the public interface of the class:
TApplicationVersion = class public constructor Create(const Filename: string); destructor Destroy; override; class function VersionToString(Version: int64): string; class function StringToVersion(const Value: string): int64; function GetString(const Key: string; LanguageID: integer; CharsetID: integer): string; overload; function GetString(const Key, TranslationID: string): string; overload; function GetString(const Key: string; Index: integer = 0): string; overload; property Valid: boolean; property Strings[const Key: string]: string; default; property FileVersion: int64; property ProductVersion: int64; property FileFlags: DWORD; property OS: DWORD; property FileType: DWORD; property FileSubType: DWORD; property FileDate: int64; property LanguageID[Index: integer]: WORD; property CharsetID[Index: integer]: WORD; property LanguageNames[Index: integer]: string; property TranslationCount: integer; end;
As a bonus there’s also a class helper that extends TApplication
with a version info property:
TApplicationVersionHelper = class helper for TApplication public property Version: TApplicationVersion; end;
To enable the class helper you just include the ApplicationVersionHelper
unit in your uses clause.
Read the version number from a file and display it in a message box
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | uses VersionInfo; ... const Filename = 'foobar.exe'; var FVersionInfo: TVersionInfo; Version: string; begin FVersionInfo := TVersionInfo.Create(Filename); try Version := TVersionInfo.VersionToString(FVersionInfo.FileVersion); finally FVersionInfo.Free; end; ShowMessage(Format('The file %s has version %s', [Filename, Version])); end; |
Set the application title to the description value specified in the version resource
1 2 3 4 5 6 7 8 | uses Forms, VersionInfo, ApplicationVersionHelper; // Enable the class helper ... begin Application.Title := Application.Version['FileDescription']; end; |
D1 | D2 | D3 | D4 | D5 | D6 | D7 | D2005 | D2006 | D2007 |
Note: The library has only been tested with Delphi 2007, but apart from the class helper, which requires Delphi 2006 or later, I would think the code can be adapted for Delphi 4 and later with minimal modifications.
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 Unported License.
Download: | VersionInfo for Delphi |
---|---|
Version: | 1.1 |
Updated: | 2 March, 2008 |
Size: | 9.62 KB |
Notes: | |
Downloads: | 7,544 |
I don't know how to convert this to Delphi 7 - without using class helper…pls give me an idea how…
Doesn't the
TVersionInfo
class (see Example 1 above) work for you?Sorry for the late reply sir
I'm from the Philippines so i'm limited with internet connection (not 24/7) and I thank you for the prompt response. Yes sir Example 1 did work for my Delphi 7 but I was talking about
VersionInfoDemo.dpr
that was attached as a demo on VersionInfo0101.zip. It uses class helper and I can't convert it or modify it so I can also read these - 'Comments', 'CompanyName', 'FileDescription', 'InternalName', 'LegalCopyright', 'LegalTrademarks', 'OriginalFilenam', 'PrivateBuild', 'ProductName', 'SpecialBuild'Just use the
Strings
property of theTVersionInfo
class. E.g. something like this:or this:
It worked! Thank you very much Sir…..
Any chance of this being converted to Free Pascal?
I am having problems trying to convert it as an FPC newbie?
I've never used Free Pascal so I can't help you.
I suggest you ask for help on the Free Pascal message board.
Anders, find some time to join us on Lazarus project!
http://www.lazarus.freepascal.org/
I have been able to convert it to FreePascal with help from the Free Pascal forums, thanks
Is there a way of adding custom strings to the unit beyond the MS standard?
Assuming you mean is there a way to read custom strings from the version info resource, yes there is. There is no difference between the strings defined by Microsoft and custom strings.
I mean add new strings to the VersionInfo resource. Would that require an extension of the TVersionInfo class?
PS. On reflection it seems that would involve modifying the .rc file Lazarus generates, or creating my own custom version.
Um… This class only reads from the version info resource.
Even if I enabled it to also write to the resource that would not magically update the exe file or your project files where the version information originates.
In Delphi you either maintain the version resource through the project options or you can include a custom RC or RES file with the version resource. I suppose Lazarus has similar capabilities.