Defined some constants: #define VERSION_MAJOR 4
#define VERSION_MINOR 5
#define VERSION_BUILD 46
#define VERSION_QFE 11
#define VERSION_BUILD_DATE "24/05/2005"
#define VERSION_BUILD_TIME "08:37:55UTC"
#define _STR(x) #x
#define STR(x) _STR(x)
#define VERSION_NUMBER VERSION_MAJOR,VERSION_MINOR,
VERSION_BUILD,VERSION_QFE
#define VERSION_STRING STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." \
STR(VERSION_BUILD) "." STR(VERSION_QFE)
#define VERSION_COMPANY ""
#define VERSION_COPYRIGHT "(C) Gugulea 2005"
#define VERSION_TRADEMARK ""
#define VERSION_BUILD_DATE_TIME VERSION_BUILD_DATE " - " \
VERSION_BUILD_TIME
The version of a file looks like this: 4.5.46.11. The numbers represent the major, minor, build and qfe numbers of your product. I chose to modify the build number, though my solution easily supports modifications of any of the numbers and even adds more.
Put all these #defines in a version.h file, which I'll include in the .rc file: #ifndef _MAC
#include "version.h"
.........................
#endif
because only some of these numbers/strings are modified, I have separated them into version.ver:
#define VERSION_MAJOR 4
#define VERSION_MINOR 5
#define VERSION_BUILD 46
#define VERSION_QFE 11
#define VERSION_BUILD_DATE "24/05/2005"
#define VERSION_BUILD_TIME "08:37:55UTC"
and version.h:
#include "version.ver"
#define _STR(x) #x
#define STR(x) _STR(x)
#define VERSION_NUMBER VERSION_MAJOR,VERSION_MINOR,
VERSION_BUILD,VERSION_QFE
#define VERSION_STRING STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." \
STR(VERSION_BUILD) "." STR(VERSION_QFE)
#define VERSION_COMPANY ""
#define VERSION_COPYRIGHT "(C) Gugulea 2005"
#define VERSION_TRADEMARK ""
#define VERSION_BUILD_DATE_TIME VERSION_BUILD_DATE " - " \
VERSION_BUILD_TIME
version.h includes version.ver and is included by the .rc file, therefore instead of adding the version numbers directly into the .rc files I have separated them into more files. The only file that will be modified is the version.ver file, which is pretty simple and easy to maintain and modify, and it will be the only one that will be automatically modified on each build.
The .rc file will look like this:
#ifndef _MAC
#include "version.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_NUMBER
PRODUCTVERSION VERSION_NUMBER
...
VALUE "Build Date", VERSION_BUILD_DATE_TIME "\0"
VALUE "CompanyName", VERSION_COMPANY "\0"
VALUE "FileVersion", VERSION_STRING "\0"
VALUE "LegalCopyright", VERSION_COPYRIGHT "\0"
VALUE "LegalTrademarks", VERSION_TRADEMARK "\0"
VALUE "ProductVersion", VERSION_STRING "\0"
...
#endif
The "Build Date" string is added manually and will appear in the version tab of the module, DLL or EXE.
Now there is another problem with Visual C++ and .rc files. If you modify some of the resources or add new resources to your application it will overwrite the version strings. Therefore you can put all the previous part in a .rc2 file, which you can include in the .rc file.
That's all, the two files that you have included in the resource files are: version.h and version.ver. The last one will be modified by an external application, whereas the resource files are not touched. The file makeversion.exe will update the VERSION_BUILD_DATE and the VERSION_BUILD_TIME values to the current ones and will increment the VERSION_BUILD number. You can modify it to update any of the numbers in version.ver, like for example VERSION_MINOR.