Menu

TEmbeddedVersionInfo

Krzysztof Kamil Jacewicz

TEmbeddedVersionInfo

A class for reading VS_VERSION_INFO record directly from an executable file.

Declaration

Unit: [atuLazVersionInfo] (see trunk version)

  TEmbeddedVersionInfo
  = Class
      Public
        Constructor Create(AFilename: string);
        Destructor Destroy; override;
      //METHODS:
        Function LoadFromFile(const AFilename: string): Boolean;
      //PROPERTIES:
        Property Version[Index: byte]: word;
        Property VersionMajorNumber: word;
        Property VersionMinorNumber: word;
        Property VersionReleaseNumber: word;
        Property VersionBuildNumber: word;
        Property VersionInfoOffset: longint;
        Property KeyCount: integer;
        Property Keys[const Index: integer]: string;
        Property Values[const Key: string]: string;
        Property ValueByIndex[const Index: integer]: string;
        Property HasVersionInfo: Boolean;
        Property Comments: string read;;
        Property CompanyName: string;
        Property FileDescription: string;
        Property FileVersion: string;
        Property InternalName: string;
        Property LegalCopyright: string;
        Property LegalTrademarks: string;
        Property OriginalFilename: string;
        Property ProductName: string;
        Property ProductVersion: string;
    End;

Methods:

  • Function LoadFromFile(const AFilename: string): Boolean;
    Reads a file specified by AFilename argument, and returns True if the file exists, can be read, and a VERSION_INFO can be extracted from it.
    Class constructor automatically calls this method.
    After this method runs you should check HasVersionInfo property to confirm that VERSION_INFO was indeed extracted.

Properties:

  • Property Version[Index: byte]: word;
    You can access portions of FileVersion value as word values. The portions are indexed from 0 to 3, and correspond to: mjor.minor.release.build fragments.

  • Property VersionMajorNumber: word;
    Direct access to the major number of the version

  • Property VersionMinorNumber: word;
    Direct access to the minor number of the version
  • Property VersionReleaseNumber: word;
    Direct access to the release number of the version
  • Property VersionBuildNumber: word;
    Direct access to the build number of the version
  • Property VersionInfoOffset: longint;
    The offset in bytes from the beginning of the file where the VS_VERSION_INFO record has been found embedded
  • Property KeyCount: integer;
    Returns the number of keys defined for the VS_VERSION_INFO structure
  • Property Keys[const Index: integer]: string;
    Returns textual name of a key at the specified index, or an empty string if the index is out of bounds. This can be used for printing both keys and values in a loop.
  • Property Values[const Key: string]: string;
    Returns text value of a key specified by a key textual name, or an empty string if the key name is invalid. The complete list of supported keys is in the VS_KEYS array of constants in the [atuLazVersionInfo] unit, starting from the index #1 (At the index #0 is a constant for locating VS_VERSION_INFO record in the file).
  • Property ValueByIndex[const Index: integer]: string;
    Returns text value of a key specified by its index, or an empty string if the Index is out of bounds
  • Property HasVersionInfo: Boolean;
    Returns TRUE if a file has been read and VS_VERSION_INFO has been found and parsed. Otherwise it returns FALSE. The value of this property is set by the LoadFromFile method, shich is also invoked inside the Constructor.
  • Property Comments: string;
    Direct access to the value of "Comments" key
  • Property CompanyName: string;
    Direct access to the value of "CompanyName" key
  • Property FileDescription: string;
    Direct access to the value of "FileDescription" key
  • Property FileVersion: string;
    Direct access to the value of "FileVersion" key. If this value is a properly formatted version string (major.minor.release.build) then you can also read the parts of the version as word values either by an array access via Version[] property, or via direct properties corresponding to each part of the version.
  • Property InternalName: string;
    Direct access to the value of "InternalName" key
  • Property LegalCopyright: string;
    Direct access to the value of "LegalCopyright" key
  • Property LegalTrademarks: string;
    Direct access to the value of "LegalTrademarks" key
  • Property OriginalFilename: string;
    Direct access to the value of "OriginalFilename" key
  • Property ProductName: string;
    Direct access to the value of "ProductName" key
  • Property ProductVersion: string;
    Direct access to the value of "ProductVersion" key

Related

Wiki: atuLazVersionInfo

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.