且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C ++/CLI winform项目中更改应用程序图标?

更新时间:2023-02-17 08:29:18

您可以尝试在此MSDN页面上发布的方法.它获得了六票赞成,因此似乎奏效.

You could try the method that was posted on this MSDN page. It got six up votes so it seemed like it worked.

链接:更改.exe图标

Windows选择主要可执行文件图标的方式是,它在可执行文件的资源部分中查找第一个图标,或者沿这些行查找.首先,您需要添加资源脚本.rc文件.这是通过项目"->添加新项目"或右键单击解决方案资源管理器并转到添加->新项目"来完成的.选择资源"->重新分配文件(.rc)"的名称,然后将其添加.

The way Windows chooses the icon of the main executable file is that it looks for the first icon in the resource section of the executable, or something along these lines. First of all, you need to add a resource script, .rc file. This is done through Project->Add New Item or right click on solution explorer and go to Add->New Item. Chose Resource->Resrouce File(.rc) name it then add it.

现在您有了资源文件,然后向其添加图标.转到资源视图,然后右键单击资源文件的名称.在底部的右侧,您将找到添加资源",选择添加资源",然后会弹出一个新窗口.

Now you have the resource file then you add the icon to it. Go to resource view and right click on the name of your resource file. Right at the bottom you will find Add Resource, select that then a new window will pop up.

如果已经单独保存了图标,则应选择导入",然后导入图标.否则,选择图标",然后按新建".该图标将被创建和/或添加到资源脚本中,并且您会发现在构建项目时它将成为可执行文件的图标.

If you already have your icon saved seperatly then you should choose Import and then import the icon. Otherwise select Icon and then press New. The icon will be created and/or added to the resource script and you will find that when you build your project it will be the icon for the executable file.

如果在项目中需要多个图标,请确保首先将所需的图标添加为可执行图标,否则必须更改资源标识符并将该图标作为最低ID.

If you want more than one icon in a project, make sure to add the one you want as the executable icon first, otherwise you will have to change the resource identifiers and put that icon as the lowest id.

您可以采用的另一种方法是

Another approach you could take is to

  • 转到您的项目文件夹.
  • 使用相同格式的新图标覆盖该文件夹中的app.ico文件.
  • 清理项目.
  • 重建.