C# 使用 Reshacker 更改可执行文件的图标
这里有多个线程询问如何更改图标 - 几乎所有线程都说使用命令行工具,例如 ResHacker - 但没有一个线程(我见过)解释如何执行此操作。我阅读了 ResHacker 的帮助文件,发现一些文本解释了如何更改 win32 可执行文件的图标。
我尝试了下面的代码,它给了我以下错误: 代码:
p.StartInfo.Arguments = "-addoverwrite " + txtProtect.Text + "," + txtProtect.Text + "," + sICOpath + "," + "ICONGROUP" + ", MAINICON, 0";
错误:
“C:\Users\Evan\Desktop\ResHacker.exe”-addoverwrite C:\Users\Evan\Desktop\output.exe,C:\Users\FARINA_EVAN\Desktop\output.exe,C:\Users\Evan \Desktop\ExeWithIcon.exe,ICONGROUP, MAINICON, 0
错误:资源类型无效。
There are MULTIPLE threads here asking how to change an icon - and nearly all of them say to use a command line tool such as ResHacker - but none of them (that I have seen) explain how to do so. I read into ResHacker's help file, and I found some text which explained how to go about changing the icon of a win32 executable file.
I tried the below code, and it gave me the following error:
Code:
p.StartInfo.Arguments = "-addoverwrite " + txtProtect.Text + "," + txtProtect.Text + "," + sICOpath + "," + "ICONGROUP" + ", MAINICON, 0";
Error:
"C:\Users\Evan\Desktop\ResHacker.exe" -addoverwrite C:\Users\Evan\Desktop\output.exe,C:\Users\FARINA_EVAN\Desktop\output.exe,C:\Users\Evan\Desktop\ExeWithIcon.exe,ICONGROUP, MAINICON, 0
Error: Invalid resource type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我意识到这有点……旧了,但这不起作用的原因是因为您试图从 .exe 中获取图标,而该图标不适用于 ResHacker 的命令行。
我唯一能想到的就是从 .exe 中提取图标并将其另存为 .ico。
然后你就可以进行“推”了。
I realize that this is a bit... Old, but the reason this won't work is because you're trying to get the icon FROM a .exe, which doesn't work with the command line of ResHacker.
The only thing I can think of is to Extract the icon from the .exe and save it as a .ico.
Then you can do the "push."
除了像您尝试那样通过 C# 操作命令行之外,我无法找到有关如何以编程方式运行 ResHacker 的任何内容。但是,为了解决您问题的根源,我在这里为您找到了一个不需要 ResHacker 的可能解决方案。相反,它允许您通过代码(C# 和 VB.NET)修改图标。这是链接:
http://www.hackforums.net/ archive/index.php/thread-422072-1.html
I wasn't able to find anything on how to programmatically run ResHacker except through manipulating the command line through C# like you are attempting to do. However, to speak to the root of your question, I found a possible solution for you here that does not require ResHacker. Instead, it allows you to modify the icon through code (C# and VB.NET). Here is the link:
http://www.hackforums.net/archive/index.php/thread-422072-1.html