[英]How to apply compiler rules when resource.h or icon.ico should be included in the exe?
I am using #define and #ifndef to strip down the exe size, i noticed the resource.h and icon.ico files eat a lot of space, so i would like to not include those in my exe at all. 我正在使用#define和#ifndef缩小exe大小,我注意到resource.h和icon.ico文件占用了很多空间,因此我根本不想在exe文件中包含这些文件。
How do i add rule for this that obeys my #define commands ? 我该如何添加遵守#define命令的规则? I could edit the resource.h, but every time i change it, it would get overwritten by Visual Studio.
我可以编辑resource.h,但是每次更改它时,Visual Studio都会覆盖它。
Edit: i dont know what is the correct name for these resource things, but my "resource.h" includes the window menu option stuff etc. 编辑:我不知道这些资源的正确名称是什么,但是我的“ resource.h”包括窗口菜单选项等。
How much is "a lot of space" that you speak of? 您说的“很多空间”是多少?
resource.h
is used for #define
-ing constants that identify resources, eg they're just numbers. resource.h
用于#define
-ing常量标识资源,例如他们只是数字。 They shouldn't be a factor in executable size. 它们不应成为可执行文件大小的因素。
What is a factor in executable size is the resources that you embed in the executable, specified by a *.rc file. 可执行文件大小的一个因素是您嵌入到可执行文件中的资源,由* .rc文件指定。 icon.ico takes up space in the *.exe because the compiler embeds the binary of the icon into the executable file itself.
icon.ico占用* .exe中的空间,因为编译器将图标的二进制文件嵌入可执行文件本身中。 This icon is specified in an *.rc file that should be somewhere in your project.
此图标在* .rc文件中指定,该文件应位于项目中的某个位置。
You can choose to remove the icon from the *.rc file and store it separately from the *.exe file, but it's easier to just embed it into the executable. 您可以选择从* .rc文件中删除该图标,然后将其与* .exe文件分开存储,但是将其嵌入可执行文件中会更容易。 The information for defining menus, icons, dialogs, etc. has to be stored somewhere, after all.
毕竟,用于定义菜单,图标,对话框等的信息必须存储在某个地方。
Edit: You can have multiple resource files, so Visual Studio doesn't overwrite your directives. 编辑:您可以有多个资源文件,因此Visual Studio不会覆盖您的指令。 Refer to http://msdn.microsoft.com/en-us/library/6t3612sk(v=VS.80).aspx to see how Visual Studio handles multiple resource files.
请参阅http://msdn.microsoft.com/zh-cn/library/6t3612sk(v=VS.80).aspx,以了解Visual Studio如何处理多个资源文件。 The section called " Using Multiple Resource Files in the Same Project " seems to be relevant to your problem.
名为“ 在同一项目中使用多个资源文件 ”的部分似乎与您的问题有关。
In VS2010, properties for icon resources include an item "Condition" which is described as "Specifies the preprocessor symbol that determines the inclusion of the resource". 在VS2010中,图标资源的属性包括项“条件”,该条件被描述为“指定确定包含资源的预处理器符号”。
Can you upgrade? 你可以升级吗?
The edit window is disabled though, you have to jump through some hoops to set the Condition. 但是,编辑窗口已禁用,您必须跳过一些设置条件。 Right-click the resource and choose "Insert Copy", then you can set the condition, then delete the original unconditional icon.
右键单击资源,然后选择“插入副本”,然后可以设置条件,然后删除原始的无条件图标。
Maybe this trick would work in VS2008 as well, don't have it installed on this computer so I can't test it. 也许这个技巧也可以在VS2008中使用,但不要在此计算机上安装它,因此我无法对其进行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.