Create a file in your project called "filever.rc2", for example.
filever.rc2 should look like this:
#include "version.h"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILE_VERSION
PRODUCTVERSION VER_PRODUCT_VERSION
FILEFLAGSMASK 0x3fL
FILEFLAGS VER_FILEFLAGS
FILEOS VER_FILEOS
FILETYPE VER_FILETYPE
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", VER_COMPANY_STR "\0"
VALUE "FileDescription", "Your Application"
VALUE "FileVersion", VER_FILE_VERSION_STR "\0"
VALUE "InternalName", "Your"
VALUE "LegalCopyright", VER_COPYRIGHT_STR "\0"
VALUE "LegalTrademarks", VER_TRADEMARK_STR "\0"
VALUE "OriginalFilename", "Your.exe"
VALUE "ProductName", "Your Application"
VALUE "ProductVersion", VER_PRODUCT_VERSION_STR "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
The information in 'filever.rc2' was copied and pasted out of the existing auto-generated .rc file for the project. Then it was modified to use the defined identifiers. The #include "version.h" will be where the defines come from. This file can be part of your application, where you can modify the version information from visual studio.
In the file "version.h", add things like:
#define VERSION_YEAR 16 // 2 digit year
#define VERSION_MONTH 4 // 2 digit month
#define VERSION_DAY 22 // 2 digit day
#define VERSION_UNSAFE 0 // 0 = TESTED, 1 = UNSAFE / IN DEVELOPMENT
#define VER_COPYRIGHT_STR "Copyright (C) 1999 - 2016"
#define VER_TRADEMARK_STR "Your Trademark"
#define VER_COMPANY_STR "Your Company"
#define STRINGIZE2(s) #s
#define STRINGIZE(s) STRINGIZE2(s)
#if (VERSION_UNSAFE == 1)
#define MY_VERSION_NUM STRINGIZE(VERSION_YEAR) STRINGIZE(VERSION_MONTH) "." STRINGIZE(VERSION_DAY) STRINGIZE(VERSION_UNSAFE)
#else
#define MY_VERSION_NUM STRINGIZE(VERSION_YEAR) STRINGIZE(VERSION_MONTH) "." STRINGIZE(VERSION_DAY)
#endif
#define VER_FILE_VERSION VERSION_YEAR, VERSION_MONTH, VERSION_DAY, VERSION_UNSAFE
#define VER_FILE_VERSION_STR STRINGIZE(VERSION_YEAR) "." STRINGIZE(VERSION_MONTH) "." STRINGIZE(VERSION_DAY) "." STRINGIZE(VERSION_UNSAFE)
#define VER_PRODUCT_VERSION VER_FILE_VERSION
#define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR
#ifdef _DEBUG
#define VER_VER_DEBUG VS_FF_DEBUG
#else
#define VER_VER_DEBUG 0
#endif
#define VER_FILEOS VOS_NT_WINDOWS32
#define VER_FILEFLAGS VER_VER_DEBUG
#define VER_FILETYPE VFT_APP
Now, go to the resource browser, and right click on the resource folder for the project you are working on. Click on "resource includes".
Add:
#include "filever.rc2"
to the list of includes under "Read-only symbol directives".
This will get the filever.rc2 file included into the resource file. Click OK. There will be a warning about making the change. Hit ok to go on and make the change.
Now, browse to the "Version" folder in the resource file.
Open that folder, right click on the version entry, and select delete to delete the version entry. If it is not deleted, there will be a duplicate resource, because we added the same information in the filever.rc2 file, which we are including.
The version information is now going to be using the included version that is in filever.rc2. This way it will not be auto-generated away, which would be the case if it is in the project resource file.
From then forward, when you change the constants in version.h and build, the version information embedded into your executable will come from the version.h file.
This solution is an example of what was described in earlier posts. Hopefully this clarifies how to implement what was suggested.
I am not sure that there is anything magic about the '.rc2' extension on the filever.rc2 file, but I found out by experimentation that if you call it .rc it appears in the resource browser and that is not really desirable. If you call it .h, it doesn't edit well in visual studio because it tries to intellisense it and it mostly looks like errors. Calling it .rc2 seemed to make everyone happy and not cause side effects.
Cheers.