Setting application info in a Qt executable file on Windows - windows

Anyone have an tips on setting the application info (ie. right click on .exe->properties) from Qt?
I can add arbitrary version strings to Qt resource file (qrc) and display them.
But most Windows installers check the version number and I can't find a Qt way of setting these fields other than manually maintaining a separate .RC file
Some way that lets you update this from an automated build would also be nice!

Here's how I do it... add a file called resources.rc to your project with the contents:
IDI_ICON1 ICON DISCARDABLE "res/app.ico"
#include <windows.h>
#include "version.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
and a file called version.h with the contents:
#ifndef VERSION_H
#define VERSION_H
#define VER_FILEVERSION 1,0,0,0
#define VER_FILEVERSION_STR "1.0.0.0\0"
#define VER_PRODUCTVERSION 1,0,0,0
#define VER_PRODUCTVERSION_STR "1.0\0"
#define VER_COMPANYNAME_STR "Your Organization"
#define VER_FILEDESCRIPTION_STR "CoolApplication"
#define VER_INTERNALNAME_STR "CoolApplication"
#define VER_LEGALCOPYRIGHT_STR "Copyright © 2010 Your Organization"
#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved"
#define VER_LEGALTRADEMARKS2_STR VER_LEGALTRADEMARKS1_STR
#define VER_ORIGINALFILENAME_STR "coolapplication.exe"
#define VER_PRODUCTNAME_STR "CoolApplication"
#define VER_COMPANYDOMAIN_STR "example.org"
#endif // VERSION_H
and lastly to your .pro file, add: RC_FILE = resources.rc. Non-Windows platforms will ignore the value so you needn't prefix it with win32:.

Okay, two years after being asked... but maybe somebody will find it useful...
Try to use the following qmake variables:
VERSION = 0.4.0.1
QMAKE_TARGET_COMPANY = company
QMAKE_TARGET_PRODUCT = product
QMAKE_TARGET_DESCRIPTION = description
QMAKE_TARGET_COPYRIGHT = copyright
More info here.

Related

Can I have a Windows .exe file version with only three digits?

I'd like to be able to use a three-digit versioning scheme for my application; however, when I set only three digits for both the file version and the product version in my .rc file (both the string and numerical versions), Windows displays the file version as "1.0.0.0" instead of the "1.0.0" that I intended for it to be. What am I doing wrong here?
The pertinent part of my .rc file is:
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH
PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,VERSION_PATCH
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Acme Inc."
VALUE "FileDescription", "My App"
VALUE "FileVersion", VERSION_STR
VALUE "InternalName", "My App.exe"
VALUE "LegalCopyright", "Copyright © 2021 Acme Inc."
VALUE "OriginalFilename", "My App.exe"
VALUE "ProductName", "My App"
VALUE "ProductVersion", VERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
where VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, and VERSION_STR are #defines from a header that is autogenerated by CMake.

Does Windows support additional custom fields in file version information of an executable?

I am writing some code in Lazarus I want to add additional information like, FPC version, Lazarus Version, Git Commit etc.
Is it possible to add fields like this in the project?
The information at https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx gives these fields as the standard ones.
Name
Comments
CompanyName
FileDescription
FileVersion
InternalName
LegalCopyright
LegalTrademarks
OriginalFilename
PrivateBuild
ProductName
ProductVersion
SpecialBuild
There is also example code like
#define VER_FILEVERSION 3,10,349,0
#define VER_FILEVERSION_STR "3.10.349.0\0"
#define VER_PRODUCTVERSION 3,10,0,0
#define VER_PRODUCTVERSION_STR "3.10\0"
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
VALUE "Translation", 0x409, 1252
END
END
Is it possible to add your own additional fields as I have described above that will be displayed when the user clicks the file in Windows explorer or be retrieved by the FileVersionInfo function in a program.
From the response to Custom field in file version in C++ project it is possible, by adding more informaton to the StringFileInfo block from the sample in the question. That answer states that the information should be visible in the file properties dialog in Windows Explorer, but I will have to verify that.

How to set property of .exe file in qt?

Is there a way to set the property of the app.exe? I'm working on the Windows and I mean when you right click on the .exe file and you choose property and details there you can set description, version, name etc. Does anyone know the way to set it in the code?
You will need to add something like:
win32:RC_FILE = application.rc
to your .pro file. The application.rc text file may contain the following information, including the icon:
IDI_ICON1 ICON DISCARDABLE "resources/Email.ico"
# if defined(UNDER_CE)
# include <winbase.h>
# else
# include <winver.h>
# endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,4,0,0
PRODUCTVERSION 0,4,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", "My company\0"
VALUE "FileDescription", "My application\0"
VALUE "FileVersion", "0.4.0.0\0"
VALUE "LegalCopyright", "Copyright (C) 2010-2014 John Daw (email#mail.com)\0"
VALUE "OriginalFilename", "application.exe\0"
VALUE "ProductName", "My Application 0.4\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/* End of Version info */

The program name is not shown with protocol handler in Windows 7

Following this page, I could make "alert" protocol handler with Windows 7.
The registry setup is exactly the same as instructed in the page.
The problem is that the Program is not shown on dialog boxes both for IE and FF.
The protocol handler works fine.
What's wrong with this? Do I add something more in registry to show the program name?
You appear to be omitting the version resource when linking your executable. That MSDN article includes the following sample resource:
#define VER_FILEVERSION 3,10,349,0
#define VER_FILEVERSION_STR "3.10.349.0\0"
#define VER_PRODUCTVERSION 3,10,0,0
#define VER_PRODUCTVERSION_STR "3.10\0"
#ifndef DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS (VER_PRIVATEBUILD|VER_PRERELEASE|VER_DEBUG)
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", VER_COMPANYNAME_STR
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", VER_INTERNALNAME_STR
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
VALUE "ProductName", VER_PRODUCTNAME_STR
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
VALUE "Translation", 0x409, 1252
END
END
Based on David's link, I could make it shown with resource embedding.
csc prosseek.cs /resource:prosseek.resource /win32icon:prosseek.ico

Synchronizing Version Resources in Visual Studio C++ (Win32) Projects

I've got a solution with about 8 separate projects in it and every time I do a release build of the entire solution I need to make sure that the version string for the binary output of each project is the same. Is there an easy way to synchronize the VS_VERSION_INFO section of a project's resources file?
I don't know that this is the way you would want to go, but .rc files allow includes, and you can use #define values in the version block
Define version numbers in a header file
#define VER_MAJOR 8
#define VER_MINOR 00
#define VER_BUILD_HI 00
#define VER_BUILD_LO 021
#define VER_FLAGS VS_FF_PRERELEASE
// The Binary form of the version numbers
#define VER_FILE VER_MAJOR, VER_MINOR, VER_BUILD_HI, VER_BUILD_LO
#define VER_PRODUCT VER_MAJOR, VER_MINOR, 0, 0
#define VER_STR(arg) #arg
// The String form of the version numbers
#define VER_FILE_STRING VALUE "FileVersion", "8.0\0"
#define VER_PRODUCT_STRING VALUE "ProductVersion", "8.0\0"
Use them in the VS_VERSION_INFO block
#include "bversion.h" //#define values in here
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILE
PRODUCTVERSION VER_PRODUCT
FILEFLAGSMASK 0x2fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "XXX\0"
VALUE "FileDescription", "YYY\0"
VER_FILE_STRING
VALUE "InternalName", "ZZZ\0"
VALUE "LegalCopyright", "© 2009 PDQ.\0"
VALUE "LegalTrademarks", "AAA\0"
VALUE "OriginalFilename", "BBB.EXE\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "CCC\0"
VER_PRODUCT_STRING
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
Reference the one header file in all of the projects and change it before each build.
We used FinalBuilder for our builds and let it go through the files (as text files) and update them with correct version info.
The simplest way to implement this would be with a prebuild step that calls a script of some sort (sed/awk, PowerShell, etc.) for all of your resource files and drops in the correct values in the appropriate places. If you use SVN, then SubWCRev from the TortoiseSVN distribution could be used for this piece as well, and could automatically use the revision number from your repository as the version string.
You can write a bit of code using ResourceLib to do that or adopt a build process that does it for you.

Resources