Why is version info not being displayed

513 Views Asked by At

So I was developing my C++ application when a came across windows resource files (.rc), my application is in portuguese of portugal so I wrote my file like this:

MAIN ICON "icon.ico"
MAIN VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "081604b0"
        BEGIN
            VALUE "Comments", "Tenta a tua Sorte!"
            VALUE "CompanyName", "Adsglobal"
            VALUE "FileDescription", "Jogo Simples"
            VALUE "FileVersion", "1.0.0.0"
            VALUE "InternalName", "Tenta a Sorte"
            VALUE "LegalCopyright", "Copyright © Rodrigo Santos 2020"
            VALUE "OriginalName", "Tenta a Sorte"
            VALUE "ProductName", "Tenta a Sorte"
            VALUE "ProductVersion", "1.0.0.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0816, 1200
    END
END

For some reason that I don't know when I compile it with g++ and windres, I get the icon but the version info isn't displayed.
If you can help me please awnser this

1

There are 1 best solutions below

0
Remy Lebeau On BEST ANSWER

You are specifying the wrong ID for the VERSIONINFO resource. Per the VERSIONINFO documentation, the ID must be 1, not MAIN:

There are two ways to format a VERSIONINFO statement:

versionID VERSIONINFO fixed-info  { block-statement . . . }

- or -

versionID VERSIONINFO 
fixed-info
BEGIN
block-statement
...
END

Parameters

versionID

Version-information resource identifier. This value must be 1.

...

So, try this instead:

MAIN ICON "icon.ico"
1 VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "081604b0"
        BEGIN
            VALUE "Comments", "Tenta a tua Sorte!"
            VALUE "CompanyName", "Adsglobal"
            VALUE "FileDescription", "Jogo Simples"
            VALUE "FileVersion", "1.0.0.0"
            VALUE "InternalName", "Tenta a Sorte"
            VALUE "LegalCopyright", "Copyright © Rodrigo Santos 2020"
            VALUE "OriginalName", "Tenta a Sorte"
            VALUE "ProductName", "Tenta a Sorte"
            VALUE "ProductVersion", "1.0.0.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0816, 1200
    END
END

Alternatively, you can use the VS_VERSION_INFO macro, which is pre-defined in <winver.h>, eg:

#include <winver.h>

MAIN ICON "icon.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "081604b0"
        BEGIN
            VALUE "Comments", "Tenta a tua Sorte!"
            VALUE "CompanyName", "Adsglobal"
            VALUE "FileDescription", "Jogo Simples"
            VALUE "FileVersion", "1.0.0.0"
            VALUE "InternalName", "Tenta a Sorte"
            VALUE "LegalCopyright", "Copyright © Rodrigo Santos 2020"
            VALUE "OriginalName", "Tenta a Sorte"
            VALUE "ProductName", "Tenta a Sorte"
            VALUE "ProductVersion", "1.0.0.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0816, 1200
    END
END