如何将多个图标文件放入Delphi资源文件

How to get multiple icon file into Delphi resource file

我正在尝试为我的 Delphi 应用程序生成一个多尺寸图标文件,因此 Windows 将选择在每种情况下显示的最佳尺寸。

按照 https://docwiki.embarcadero.com/RADStudio/Sydney/en/Creating_and_Deploying_App_Icons

上的官方支持说明进行操作

Storing Your Icon Files into an Icon Container Once you have your app icon in all the resolutions that a target platform requires, for desktop platforms you must then archive the different resolutions of your icon into a single file, an icon container, that you can deploy along with your application.

For Windows, you must create an .ico icon container file. See How to make/get a multi size .ico file?."

它指向这个 Stack Overflow 问题:

How to make/get a multi size .ico file?

我完全按照说明进行操作,并且可以使用 ImageMagick 获得多尺寸图标文件。

问题是,当我尝试使用 BRCC32 编译我的资源文件时,出现此错误:

[BRCC32 错误]icon.rc(2):分配失败

这是我的 RC 文件的内容:

LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
MAINICON icon "myapp.ico"

如果我转到“项目”>“应用程序”>“图标”,我可以毫无问题地加载 myapp.ico,但由于我的项目的性质,我需要改用资源文件。

请帮忙,我被这个问题困了好几天了。

谢谢

来自 resource compilers 上的文档:

Both C++Builder and Delphi give you a choice of resource compilers. On the Project > Options > Resource Compiler dialog box, you can select either of the following:

  • BRCC32.exe, the C++Builder resource compiler
  • RC.exe, the Microsoft platform SDK Resource Compiler

RC supports Unicode characters in resource files and file names, as well as new Vista resource types such as icons with alpha channel.

因此,如果您需要Vista图标,您需要换成RC编译器。