How do I add custom windows' resources into executable without resource compiler?

柔情痞子 提交于 2019-12-19 10:43:15

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/6555098/how-do-i-add-custom-windows-resources-into-executable-without-resource-compiler

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