<script type="text/javascript">function loadTOCNode(){}</script> 转自MSDN :http://support.microsoft.com/kb/237870/zh-cn
创建新项目使用 MFC (EXE) Appwizard 并调用它 MyProject . MyProject 将有一个 MyProject.rc 文件, 包括 MyProject.rc2。 .rc 2 文件是用于用户定义资源。 请按照下列步骤来增加每生成后 MyProject 的版本信息:
概要
<script type="text/javascript">loadTOCNode(1, 'summary');</script>
VisualC++ 不具备功能来自动增加版本资源信息项目的各个生成后。 本文介绍一个地提供这些功能。
更多信息
<script type="text/javascript">loadTOCNode(1, 'moreinformation');</script> 您可以编写程序来修改资源编译器 (.rc) 文件而不是使用这里介绍步骤。 但是, RC 文件是个 VisualC++ 控制下。 VisualC++ 修改同时保存, RC 文件并可能会影响版本资源。 本节中介绍方法可应用于任何 VisualC++ 项目。 本示例使用 Microsoft 基础类项目。创建新项目使用 MFC (EXE) Appwizard 并调用它 MyProject . MyProject 将有一个 MyProject.rc 文件, 包括 MyProject.rc2。 .rc 2 文件是用于用户定义资源。 请按照下列步骤来增加每生成后 MyProject 的版本信息:
1. | Remove the version resource from the .rc file and place it in the .rc2 file:
| ||||||
2. | Replace the FILEVERSION and PRODUCTVERSION data with macros FILEVER and PRODUCTVER. Similarly, replace the FileVersion and ProductVersion string data with the macros STRFILEVER and STRPRODUCTVER. | ||||||
3. | Add a #include VersionNo.h immediately before the VS_VERSION_INFO resource statement. Now the version resource will look like: /// | ||||||
4. | Create a header file called VersionNo.h in the same directory as your project. This file will contain the following statements, which are the definitions for macros used in step 2: #define FILEVER 1,0,0,1NOTE: Add linefeed and carriage return characters on the last line. Now, MyProject.rc file includes MyProject.rc2, and MyProject.rc2 file includes VersionNo.h. | ||||||
5. | The VersionNo.h file contents will be modified using a Visual Basic Script macro. The macro described below handles the Visual C++ BuildFinish event, so it will not be fired until a build completes. Whenever this VB Script code is called, it first increments the version numbers inside the header file by a fixed amount, then it saves the file and closes it. During a subsequent build, the new version number is included in the executable. To install and use the VB Script code, do the following:
| ||||||
6. | Select Build MyProject.exe from the Build menu. After the build finishes, open the VersionNo.h file. It will contain the following statements: #define FILEVER 1,0,0,2If you build the code again, this version information in included in the executable, and the version information is incremented. You can introduce some code in the macro described earlier to prevent incrementing version numbers if the build produced errors. |