2009-04-27

Icon and version information resource file

This should be an update for one of the recent posts.

resource.rc:
ID ICON "path/to/my.ico"
...the ID can be anything. It doesn't matter unless it is referred in the code.

Run windres as follows:
windres resource.rc -O coff -o resource.o
Include resource.o along with other object files while linking, e.g.,
g++ -o app obj1.o obj2.o resource.o

And, at no extra charge, it is possible to include version information to the application, adding the following boilerplate to resource.rc file:
1 VERSIONINFO
FILEVERSION     1,0,0,0
PRODUCTVERSION  1,0,0,0
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904E4"
        BEGIN
            VALUE "CompanyName", "Company name"
            VALUE "FileDescription", "Application name"
            VALUE "FileVersion", "1.0"
            VALUE "InternalName", "my_app"
            VALUE "LegalCopyright", "Copyright info"
            VALUE "OriginalFilename", "my_app.exe"
            VALUE "ProductName", "My App"
            VALUE "ProductVersion", "1.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END

Links:
- Original post
- Additional info

Credit goes to Evan McLean.

No comments:

Post a Comment