如何在不使用资源编译器的情况下将自定义窗口的资源添加到可执行文件中? [英] How do I add custom windows' resources into executable without resource compiler?

查看:216
本文介绍了如何在不使用资源编译器的情况下将自定义窗口的资源添加到可执行文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够将位图对象( LoadImage )加载到可执行文件中(并将其实现为图标);但是,当我将其作为独立可执行文件释放时,图标将消失。我发现它需要位图存在于目录在运行时,这个技巧工作。但是,即使在当前目录中存在位图,我的可执行桌面图标也不会从默认图标更改。我假设这种情况发生,因为桌面图标应该在编译时确定。因此,我想知道是否有一种方法来添加资源到可执行文件,而不需要资源编译器?我的愿望是用winapi完成一切。如果这不可能,那么我会考虑替代品。

I was able to load a bitmap object (LoadImage) into executable (and implement it as an icon); however, when I release it as a standalone executable, the icon disappears. I found out that it requires the bitmap to be present in directory at runtime for this trick to work. However, my executable desktop icon will not change from default icon even with the bitmap present in current directory. I assume that this happens, because desktop icon should be determined during compiling time. Therefore, I want to know if there's a way to add resources into executable without the need of resource compiler? My desire is to have everything done with winapi. If that's not possible, then I'll consider alternatives.

推荐答案

您可以使用 BeginUpdateResource UpdateResource EndUpdateResource 将位图资源添加到可执行文件作为后构建步骤或某物,但为什么避免使用资源编译器?它比攻击你自己的解决方案更容易,更直接和面向未来。

You could use BeginUpdateResource, UpdateResource, and EndUpdateResource to add the bitmap resource to your executable as post-build step or something, but why avoid using the resource compiler? It's really much easier, more straightforward, and future-proof than hacking your own solution.

这篇关于如何在不使用资源编译器的情况下将自定义窗口的资源添加到可执行文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆