13.4 Inserting version information

The win32 API allows the storing of version information in your binaries. This information can be made visible with the Windows Explorer, by right-clicking on the executable or library, and selecting the ’Properties’ menu. In the tab ’Version’ the version information will be displayed.

Here is how to insert version information in your binary:

1 VERSIONINFO
FILEVERSION 4, 0, 3, 17
PRODUCTVERSION 3, 0, 0, 0
FILEFLAGSMASK 0
FILEOS 0x40000
FILETYPE 1
{
 BLOCK "StringFileInfo"
 {
  BLOCK "040904E4"
  {
   VALUE "CompanyName", "Free Pascal"
   VALUE "FileDescription", "Free Pascal version information extractor"
   VALUE "FileVersion", "1.0"
   VALUE "InternalName", "Showver"
   VALUE "LegalCopyright", "GNU Public License"
   VALUE "OriginalFilename", "showver.pp"
   VALUE "ProductName", "Free Pascal"
   VALUE "ProductVersion", "1.0"
  }
 }
}

As you can see, you can insert various kinds of information in the version info block. The keyword VERSIONINFO marks the beginning of the version information resource block. The keywords FILEVERSION, PRODUCTVERSION give the actual file version, while the block StringFileInfo gives other information that is displayed in the explorer.

The Free Component Library comes with a unit (fileinfo) that allows to extract and view version information in a straightforward and easy manner; the demo program that comes with it (showver) shows version information for an arbitrary executable or DLL.