2

This is my version.rc:

#define VER_FILEVERSION             1,2,3,4
#define VER_FILEVERSION_STR         "1.02.03.04\0"

1               VERSIONINFO
FILEVERSION     VER_FILEVERSION
PRODUCTVERSION  VER_FILEVERSION
FILEOS          VOS__WINDOWS32
FILETYPE        VFT_APP
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName",      VER_FILEVERSION_STR
            VALUE "FileDescription",  VER_FILEVERSION_STR
            VALUE "FileVersion",      VER_FILEVERSION_STR
            VALUE "InternalName",     VER_FILEVERSION_STR
            VALUE "LegalCopyright",   VER_FILEVERSION_STR
            VALUE "LegalTrademarks1", VER_FILEVERSION_STR
            VALUE "LegalTrademarks2", VER_FILEVERSION_STR
            VALUE "OriginalFilename", VER_FILEVERSION_STR
            VALUE "ProductName",      VER_FILEVERSION_STR
            VALUE "ProductVersion",   VER_FILEVERSION_STR
        END
    END
END

My program starts like this:

program TestProgram;
{$R 'version.res' 'version.rc'}

But the string info I set isn't in the executable:

Explorer showing file version info

The config I'm using has the "include version information in project" off, since I'm including it in the .RC file instead. What am I doing wrong ?

Note that if I open the .EXE as text and look for CompanyName, I do find it and the next char is NUL, then another seemingly random char then the next string info header.

1 Answer 1

1

Found it: VarFileInfo isn't optional. This is working:

#define VER_FILEVERSION 1,2,3,4
#define VER_FILEVERSION_STR "1.02.03.04\0"

1 VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_FILEVERSION
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName", VER_FILEVERSION_STR
            VALUE "FileDescription", VER_FILEVERSION_STR
            VALUE "FileVersion", VER_FILEVERSION_STR
            VALUE "InternalName", VER_FILEVERSION_STR
            VALUE "LegalCopyright", VER_FILEVERSION_STR
            VALUE "LegalTrademarks1", VER_FILEVERSION_STR
            VALUE "LegalTrademarks2", VER_FILEVERSION_STR
            VALUE "OriginalFilename", VER_FILEVERSION_STR
            VALUE "ProductName", VER_FILEVERSION_STR
            VALUE "ProductVersion", VER_FILEVERSION_STR
        END
    END

    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END
1
  • VarFileInfo is the index on which blocks of info exist. The languages are meant for the version info only, so if you have only language independent values like numbers in there use the language code 00000000 in the block (and 0, 0 in the index). Also note that you don't need to define all the VALUEs in the block - you can also shrink it down to FileVersion and ProductVersion (or even define your own, but the Explorer doesn't display those anymore since at least Windows 7).
    – AmigoJack
    Commented Sep 12 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.