windows 是否有命令行实用程序可以更改 win32 exe 的嵌入图标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1207965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a command line utility to change the embedded Icon of a win32 exe?
提问by jkp
...id like something I could integrate into my build process: is there anything "standard" tool that does this?
...id 喜欢我可以集成到我的构建过程中的东西:有什么“标准”工具可以做到这一点?
回答by Alan
Have you seen Resource Hacker? You can also drive it via the command line(script) so I'm sure it could be incorporated into your build.
回答by Javed Ahamed
I am pretty sure Resource Hackercan do this, and some other things, I believe i recognize its icon from when i used it a while back. Hope that helps you!
我很确定Resource Hacker可以做到这一点,还有其他一些事情,我相信我在不久前使用它时就认出了它的图标。希望能帮到你!
回答by Ville Laurikari
You need to create a resource script file (.rc
), and then compile it to an object file with rc
(.rc
→ .res
) and cvtres
(.res
→ .obj
). Both tools are included in the Microsoft Platform SDK. When you include the object file into an linker command, the result will have the icon specified in the resource script file. Here's a sample resource file and the commands to create the object:
您需要创建一个资源脚本文件 ( .rc
),然后使用rc
( .rc
→ .res
) 和cvtres
( .res
→ .obj
)将其编译为目标文件。这两个工具都包含在 Microsoft 平台 SDK 中。当您将目标文件包含到链接器命令中时,结果将具有资源脚本文件中指定的图标。这是一个示例资源文件和创建对象的命令:
resource.rc:
资源.rc:
101 ICON "my_icon.ico"
Your icon file is in the file my_icon.ico
. Commands to compile these into an object file:
您的图标文件在文件中my_icon.ico
。将这些编译成目标文件的命令:
rc -fo resource.res resource.rc
cvtres -machine:ix86 -out:resource.obj resource.res
But, by far the easiest way to set the program icon is to just do it in Visual Studio.
但是,到目前为止,设置程序图标的最简单方法是在 Visual Studio 中进行。
Technically, neither will allow you to actually changethe icon of an existing executable, but somehow I doubt that's what you really want to do.
从技术上讲,两者都不允许您实际更改现有可执行文件的图标,但不知何故,我怀疑这是否是您真正想要做的。
回答by jkp
Looks like I've found the perfect solutionfor what I'm trying to do.
看起来我已经为我正在尝试做的事情找到了完美的解决方案。