Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

c++ - How to change an executable's properties? (Windows)

When I create a .exe, I can right click it and go to properties->details. Then I get a list like:

File Description | 
Type             | Application
File Version     | 
Product Name     | 
Product Version  |
Copyright        | 
Size             | 18.0 KB
Date Modified    | 6/16/2009 8:23 PM
Language         |

How do I change these properties? (And on a side note, is there a way to change the icon?)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are using C/Win32 you can add something like this to your project encapsulated in a *.rc (resource) file:

VS_VERSION_INFO VERSIONINFO
 FILEVERSION    0,0,0,2
 PRODUCTVERSION 0,0,0,2
 FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
 FILEFLAGS 0x1L
 #else
 FILEFLAGS 0x0L
 #endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
{
    BLOCK "StringFileInfo"
    { 
        BLOCK "040904b0"
        {
            VALUE "Comments",         "comment"
            VALUE "CompanyName",      "comment"
            VALUE "FileDescription",  "base file"
            VALUE "FileVersion",      "0.0.0.2 TP"
            VALUE "InternalName",     "testTP"
            VALUE "LegalCopyright",   "none"
            VALUE "OriginalFilename", "test.exe"
            VALUE "ProductName",      "test"
            VALUE "ProductVersion",   "0.0.0.2 TP"
        } 
    }
    BLOCK "VarFileInfo"
    {
        VALUE "Translation", 0x409, 1200
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...