VC++ 2012: How to include version info from version.inc (maintained separately) into the .rc file

Deadly 提交于 2019-12-04 03:12:57

Here is the way to do it via Visual Studio 2012 (C++, IDE). Firstly, it seems that all the files (app.rc, version.rc2 with the version section to be included into app.rc, and also the version.inc with the values maintained separately [included into version.rc2]) must be stored in UTF-16 -- unlike in the earlier versions of Visual Studio. Then I was able to repeat the same approach also in Visual Studio 2012.

However, you do not need to edit the app.rc file manually. You can use the following steps using the IDE:

  • Open the project (App) and switch to the Resource View tab.
  • Unfold the App project, unfold its app.rc, and unfold the Version folder. You can see the VS_VERSION_INFO item.
  • Mark the VS_VERSION_INFO item and pres Delete key on the keyboard. The item and its upper Version folder disappear.
  • Mouse right-click the app.rc folder, and select the Resource Includes.... The dialog with the same name and with three input panes appear.

  • Focus on the bottom pane named Compile-time directives:, and write the #include "version.rc2" there. (The file must not have the .rc extension, but the .rc2 is fine and recommended elsewhere in the MSDN doc.)
  • Press OK, and save all files (to save also the modified app.rc).

The result of the steps is that you will not see the Version folder and the VS_VERSION_INFO item in the resource tree (see Resource View tab); however, the above mentioned constructed Version section (stored inside the version.rc2) is compiled into the application resources.

Technically, the following parts of the app.rc file can be found after the steps:

3 TEXTINCLUDE 
BEGIN
    "#include ""version.rc2""\r\n"
    "\0"
END

...

#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#include "version.rc2"

/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

Any constructive comments to enhance the topic are welcome and will be +1-ed :)

Have a nice time,

Petr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!