我想根据 Activex 控件是 32 位控件还是 64 位控件来切换用于 ActiveX 控件的 GUID。我宁愿没有两个 .rc 文件来执行此操作。但是,资源编译器会忽略 BEGIN - END block 内的预处理器定义,并且始终默认为 #else 部分中的 Control。请告诉我除了使用两个不同的资源(.rc)文件之外是否有更好的方法来执行此操作。
BEGIN
#ifdef _Win64
CONTROL "",IDC_TCHART1,"{FCB4B50A-E3F1-4174-BD18-54C3B3287258}",WS_TABSTOP,0,15,445,199
#else
CONTROL "",IDC_TCHART1,"{FAB9B41C-87D6-474D-AB7E-F07D78F2422E}",WS_TABSTOP,0,15,445,199
#endif
END
最佳答案
我认为它无法识别编译器选项的项目属性中定义的预处理器符号,您也需要将其添加到资源属性中。此外,您还可以 #include 包含 #define
符号的文件。
所以as MSDN says :
To define symbols for your resource identifiers, use the #define directive to define them in a header file. Include this header both in the resource script and your application source code. Similarly, you define the values for resource attributes and styles by including Windows.h in the resource script.
RC treats files with the .c and .h extensions in a special manner. It assumes that a file with one of these extensions does not contain resources. If a file has the .c or .h file name extension, RC ignores all lines in the file except the preprocessor directives. Therefore, to include a file that contains resources in another resource script, give the file to be included an extension other than .c or .h.
话虽如此,一旦您使用 Visual Studio 资源编辑器修改此内容,您很可能就会丢失所做的更改。
关于.rc 文件中的宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23413739/