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.
Related
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.
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 */
I want to use a resource script for my project. The project is compiled using MinGW.
resource.rc:
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
//FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
//FILEFLAGS VER_PRIVATEBUILD
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
//VALUE "Comments", ""
VALUE "CompanyName", "Company"
VALUE "FileDescription", "Test for the resource.rc"
VALUE "FileVersion", "1.0"
VALUE "InternalName", "ResourceTest"
//VALUE "LegalCopyright", ""
//VALUE "LegalTrademarks1", ""
//VALUE "LegalTrademarks2", ""
VALUE "OriginalFilename", "ResourceTest.exe"
VALUE "PrivateBuild", "Built by me." //With VS_FF_PRIVATEBUILD
VALUE "ProductName", "resource.rc Test"
VALUE "ProductVersion", "1.0"
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", 0x407, 1252 //German
VALUE "Translation", 0x409, 1252 //U.S. English
END
END
I compile it using windres -o Resource.o resource.rc and link it with gcc -mwindows -o Resourcetest.exe Launcher.o Resource.o. My console output:
windres -o Resource.o resource.rc
windres: resource.rc:39: syntax error
make: *** [Resource.o] Error 1
Line 39 is the second Translation line: VALUE "Translation", 0x409, 1252. But refering to MSDN this is currect. But what went wrong?
You can't have multiple VALUE "Translation" lines in the VarFileInfo block. Instead, as the comment says, you must have a single line with one or more WORD,WORD pairs.
For example,
VALUE "Translation", 0x407, 1252, 0x409, 1252
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
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.