TPJVersionInfo is a non-visual component that reads version information contained in a 32 bit or 64 bit Windows executable file.
The component reads information from a designated file's VERSIONINFO resource. The required file is specified in the component's FileName property. Setting FileName to the empty string fetches the version information of the executable file containing the component. The Boolean HaveInfo property indicates whether the file contains version information. This component can access variable file information for each language provided in the resource.
Features
Run-time properties enable access to the version information. Properties enable:
-
Access to fixed file information, either by field or the whole record.
-
Access to the number of translations stored in the version information.
-
Selection of the translation for which information is to be returned by other properties.
-
Access to the language and code page of the current translation – by code and by name.
-
Access to the string file information for the current translation – named properties access the Microsoft-defined string information, while an array property gives access to any string item by name.
Version numbers are encapsulated in TPJVersionNumber records which, on Delphi 2006 or later, can be directly assigned to a string and can be compared using the normal equality operators. Helper functions that can compare and format version numbers as text are provided for use with Delphi 2005 and earlier.
The component makes calls to the Windows API when reading version information. Therefore the version information being read must follow the Microsoft guidelines. Be warned that not all software complies!
For detailed information about version information refer to the Windows SDK.
Demo code
The source code for two demo projects is included. The demos are:
-
VIDemo.dpr
is an application that can extract and display version information from any program, provided that the program has valid version information.
-
HelpEgs.dpr
implements all the examples from the component help file.
The demos required Delphi 7 and higher.