Visual Studio 2005. RC File includes

前端 未结 5 462
日久生厌
日久生厌 2021-01-11 23:31

I\'m programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include \"blah.h\"), at the top of an .rc

相关标签:
5条回答
  • 2021-01-12 00:04

    You want to Include Resources at Compile Time (MSDN).

    0 讨论(0)
  • 2021-01-12 00:07

    Add your #include to the file in the normal way, but also add it to one the three "TEXTINCLUDE" sections in the file, like so:

    2 TEXTINCLUDE
    BEGIN
        "#include ""windows.h""\r\n"
         "#include ""blah.h\r\n"
         "\0"
     END
    

    Note the following details:

    • Each line is contained in quotes
    • Use pairs of quotes, e.g., "" to place a quote character inline
    • End each line with \r\n
    • End the TEXTINCLUDE block with "\0"

    Statements placed in the "1 TEXTINCLUDE" block will be written to the beginning of the .rc file when the file is re-written by the resource editor. Statements placed in the 2 and 3 blocks follow, so you can guarantee relative include file order by using the appropriately numbered block.

    If your existing rc file does not already include TEXTINCLUDE blocks, use the new file wizard from the Solution Explorer pane to add a new rc file, then use that as a template.

    0 讨论(0)
  • 2021-01-12 00:07

    Within Visual Studio IDE, right-click on the .rc file (in the Resource View panel), and select "Resource includes" from the shortcut menu. When the dialog opens, use its "Compile-time directives" area to enter whatever you want to include in the .rc file. For example, if you want your 64-bit and 32-bit builds to use different icons, you could include the appropriate resource file for each build as follows:

    #ifdef WIN64
    #include "Icons64.rc"
    #else
    #include "Icons32.rc"
    #endif
    

    It's worth noting that these defines are not set in the resource compiler by default, so for your 64 bit build make sure you add /DWIN64 to the rc build.

    0 讨论(0)
  • 2021-01-12 00:11

    All the gory details can be found in MFC Technote #35.

    -Ron

    0 讨论(0)
  • 2021-01-12 00:15

    I'm not completely sure why you're trying to do, but modifying the resource files manually probably isn't a good idea.

    I believe general practice for VC++ for globally-accessible values is to define them in stdafx.h (at least that's how I've seen it done), or to create something like a "globals.h" header file and include that wherever you need it. It really depends on what you're trying to accomplish though.

    0 讨论(0)
提交回复
热议问题