Solved Using RC_FILE for an icon + embedded manifest + file properties
-
Reposting this topic (with the replies) without a part of the code that shouldn't have been posted. I would have edited but it was also quoted... I'll mark as solved once I confirm a solution.
I'm switching from MSVC to MinGW for my project, now on Qt 5.7.
I used to modify some of the target executable's file and version information with my .pro file, using variables like
QMAKE_TARGET_COPYRIGHT, QMAKE_TARGET_COMPANY
, etc. That along with usingVERSION
andRC_ICONS
would work fine. I also embedded a manifest because of a dependency, using the mt.exe tool.Now, however, I want everything to work with MinGW.
So instead of the other keys I mentioned, I made a MyApp.rc file and referenced it in the .pro file:
RC_FILE = MyApp.rc
Inside the file I used the following code:
1 ICON "MyApp.ico" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "MyDependency.dll.manifest" 2 VERSIONINFO FILEVERSION 2,0,0,0 PRODUCTVERSION 2,0,0,0 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", "MyCompany" VALUE "FileDescription", "Description" VALUE "InternalName", "MyApp" VALUE "LegalCopyright", "Copyright 2016 Me" VALUE "ProductName", "My Product" END END END
I see the icon updated but when I try to right-click the executable and check for properties of the file I don't see the version information parts. I'm using Windows 10.
Can anyone help with a working RC_FILE example? I tried several from online sources but I still get the same result.
@hskoglund said
Hi getting the version info visible with right-click in Explorer is an arcane art, try something like this:
1 ICON "MyApp.ico" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "MyDependency.dll.manifest" #include <windows.h> LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VS_VERSION_INFO VERSIONINFO FILEVERSION 2,0,0,0 PRODUCTVERSION 2,0,0,0 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "CompanyName", "MyCompany" VALUE "FileDescription", "Description" VALUE "InternalName", "MyApp" VALUE "LegalCopyright", "Copyright 2016 Me" VALUE "ProductName", "My Product" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1252 END END
@Paul-Colby said
Hi @frankiefrank,
Your
StringFileInfo
block is missing a lot of parameters that are stated as required in Microsoft's StringFileInfo BLOCK statement documentation, such asFileVersion
,OriginalFilename
andProductVersion
.Personally, I'd either:
- revisit / rebuild one of your older versions, and pull out its
*.rc
file to use as a starting point; and/or - take inspiration from qmake's Win32MakefileGenerator::processRcFileVar() function source; and/or
- begin with a known working
*.rc
file from another project, such as this one (here's another example from one of my open-source projects, which usesQMAKE_SUBSTITUTES
(one of qmake's lesser-known features) to still be able to use qmake variables, such as$$VERSION
, in the RC file).
Cheers.
- revisit / rebuild one of your older versions, and pull out its
-
Thank you!
I solved this by following up on @Paul-Colby 's suggestion to start with an older build's .rc file.
Here's my working version. I got my icon, my manifest AND the details appear correctly in the file properties.
# if defined(UNDER_CE) # include <winbase.h> # else # include <windows.h> # endif IDI_ICON1 ICON DISCARDABLE "MyApp.ico" CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "Drivers\\MyDependency\\MyDependency.dll.manifest" VS_VERSION_INFO VERSIONINFO FILEVERSION 2,1,0,0 PRODUCTVERSION 2,1,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS VS_FF_DEBUG #else FILEFLAGS 0x0L #endif FILEOS VOS__WINDOWS32 FILETYPE VFT_DLL FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "MyCompany\0" VALUE "FileDescription", "Description\0" VALUE "FileVersion", "2.1.0.0\0" VALUE "LegalCopyright", "Copyright 2016 Me\0" VALUE "OriginalFilename", "MyApp.exe\0" VALUE "ProductName", "App\0" VALUE "ProductVersion", "2.1.0.0\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 1200 END END /* End of Version info */
@hskoglund I tried to use what you wrote first but got an error on LANGUAGE, saying Broken Pipe, so then I went on to try the other suggestions.