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

前端 未结 6 1890
执念已碎
执念已碎 2020-12-08 10:45

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

File Description | 
Type             | Applic         


        
相关标签:
6条回答
  • 2020-12-08 11:01

    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\0"
                VALUE "CompanyName",      "comment\0"
                VALUE "FileDescription",  "base file\0"
                VALUE "FileVersion",      "0.0.0.2 TP\0"
                VALUE "InternalName",     "testTP\0"
                VALUE "LegalCopyright",   "none\0"
                VALUE "OriginalFilename", "test.exe\0"
                VALUE "ProductName",      "test\0"
                VALUE "ProductVersion",   "0.0.0.2 TP\0"
            } 
        }
        BLOCK "VarFileInfo"
        {
            VALUE "Translation", 0x409, 1200
        }
    }
    
    0 讨论(0)
  • 2020-12-08 11:02
    • Executable's Resources
    • Modifying the resources
    0 讨论(0)
  • 2020-12-08 11:03

    If you want to change the FileDescription or any other version resource string on a compiled executable, rcedit (a small open-source tool) does it pretty easily:

    $ rcedit MyApp.exe --set-version-string FileDescription "My Awesome App"
    
    0 讨论(0)
  • 2020-12-08 11:11

    This is simple file version info resource. For already existent files you can edit this information with any resource editor (for example Resource Hacker, it is outdated but still good). You can change icon this way too.

    If you create your own application, then setting it depends on tool you are using. For example in Visual Studio you must look into project properties.

    0 讨论(0)
  • 2020-12-08 11:14

    For .NET, google for "setting assembly attributes" for information on what attributes are available. You then use the attributes like so ...

    using System.Reflection;  // Needed to get to the attributes.
    
    [assembly:AssemblyTitle("My File Description")]
    [etc.]
    
    0 讨论(0)
  • 2020-12-08 11:16

    Very easy if you are using visual studio:

    • Right click on the 'Resource Files' folder in the project
    • Click 'Add' then 'Resource'
    • Choose 'Version' from the pop-up dialog

    You can then double click on the file to open it in Visual Studio, and you get a handy editor to change the values.

    Your values are then automatically linked in to the EXE.

    0 讨论(0)
提交回复
热议问题