-2

所以当我遇到 Windows 资源文件 (.rc) 时,我正在开发我的 C++ 应用程序,我的应用程序是葡萄牙语的,所以我这样写我的文件:

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

由于某种原因,我不知道什么时候用 g++ 和 windres 编译它,我得到了图标,但没有显示版本信息。
如果你能帮助我,请把这个

4

1 回答 1

2

您为VERSIONINFO资源指定了错误的 ID。根据VERSIONINFO文档,ID 必须是1,而不是MAIN

有两种方法可以格式化 VERSIONINFO 语句:

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

- 或者 -

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

参数

版本号

版本信息资源标识符。该值必须为 1。

...

所以,试试这个:

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

或者,您可以使用VS_VERSION_INFO预定义在 中的宏,<winver.h>例如:

#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
于 2020-08-21T00:13:49.233 回答