关键词:visual studio,rc file,VS_VERSION_INFO,FILEVERSION,PRODUCTVERSION
目标:希望每次在vs中编译项目时,生成的可执行程序版本号自动+1
环境:vs2010,python 2.7.8
步骤:
1.在rc文件同目录下添加version.h头文件,内容如下:
#define RELEASE_VER 1 // 0: beta version; 1: release version #define RELEASE_DATE "Sep 01 2014" // Mmm dd yyyy; only used for RELEASE_VER=1 #define RELEASE_VER_MAIN 1 // version number (binary) #define RELEASE_VER_MAIN2 0 #define RELEASE_VER_SUB 0 #define RELEASE_VER_SUB2 0 // version number (string) #define TOSTRING2(arg) #arg #define TOSTRING(arg) TOSTRING2(arg) #define RELEASE_VER_STR TOSTRING(RELEASE_VER_MAIN) "." TOSTRING(RELEASE_VER_MAIN2) "." TOSTRING(RELEASE_VER_SUB) "." TOSTRING(RELEASE_VER_SUB2)
2.用文本编辑器(notepad++)打开rc文件,修改文件内容
// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///// #undef APSTUDIO_READONLY_SYMBOLS ///// // Chinese (Simplified, PRC) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED #ifdef APSTUDIO_INVOKED ///// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3</