简体   繁体   English

更改生成的exe的图标

[英]Change icon of generated exe

I'm generating an executable file with VB.NET using CodeDomProvider. 我正在使用CodeDomProvider用VB.NET生成可执行文件。

Is there a way to change the icon before the compiler creates the exe file? 在编译器创建exe文件之前,是否可以更改图标?

You can set the icon of the generated exe by specifying it in the CompilerParameters that you pass to the code provider, using the CompilerOptions property. 您可以通过使用CompilerOptions属性在传递给代码提供程序的CompilerParameters中指定生成的exe的图标来设置它。

Dim parameters As New CompilerParameters()
parameters.CompilerOptions = "/win32icon:C:\full\path\to\icon.ico"

You then pass these parameters to the CompileAssemblyFromSource method. 然后,将这些参数传递给CompileAssemblyFromSource方法。 The generated exe will then use the specified icon as its application icon. 然后,生成的exe将使用指定的图标作为其应用程序图标。

Go into the project properties and select the icon from there. 进入项目属性,然后从中选择图标。 Simple as that. 就那么简单。

You can use RessourcesHacker AFTER the generation. 您可以在生成后使用RessourcesHacker Not the easiest way, but it works great 这不是最简单的方法,但是效果很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM