更改 Delphi 控制台应用程序的图标

发布于 2024-08-08 13:15:14 字数 72 浏览 3 评论 0原文

如何更改 Delphi 控制台应用程序的程序图标?

应用程序设置在控制台应用程序中呈灰色。

再见。

How do I change the program icon for a Delphi console application?

The application settings is greyed in a console application.

Bye.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

深爱不及久伴 2024-08-15 13:15:14

根据 2007 年 7 月的博客文章Nibu Thomas 提出,似乎有一个 SetConsoleIcon WinAPI 函数。

或者,只需将图标放入资源文件中即可。 Windows 应使用在应用程序资源中遇到的第一个图标作为应用程序图标。

According to a July 2007 blog article by Nibu Thomas, there seems to be a SetConsoleIcon WinAPI function.

Alternatively just put the icon in a resource file. Windows should use the first icon it encounters in the application's resources as the application icon.

一曲琵琶半遮面シ 2024-08-15 13:15:14

如果更改图标的选项被禁用,那么这是因为您已删除或忽略从 DPR 文件中添加以下行:

{$R *.res}

将其放回去,如果您从未有过,则添加它。图标设置将重新启用,版本信息设置也将重新启用。如果资源文件不存在,IDE 会为您创建它。不要编辑该资源文件(例如添加您自己的图标或其他资源);它仅供 IDE 使用。

If the option to change the icon is disabled, then it is because you have deleted or neglected to add the following line from your DPR file:

{$R *.res}

Put it back, or add it if you never had it. The icon setting will be re-enabled, as will the version-information settings. If the resource file does not exist, then the IDE will create it for you. Do not edit that resource file (such as to add your own icons or other resources); it is for the IDE's use only.

孤寂小茶 2024-08-15 13:15:14

如果您

application.Run; 

在 dpr 文件中添加某个位置,您可以使用项目->选项来更改图标。
更改图标后,只需删除“application.Run;”再次,您可以使用新图标进行编译/构建。

if you add

application.Run; 

somewhere in your dpr file you can use the project->options to change the icon.
After you have changed the icon just remove "application.Run;" again and you can compile/build with new icon.

飞烟轻若梦 2024-08-15 13:15:14

只需更改应用程序资源文件中的图标(假设您的应用程序项目名为 ConsoleApp.dpr,您的应用程序资源文件将为 ConsoleApp.res)。

其中的主图标资源直观地称为 MAINICON,只需替换它即可。

这是 C++ Builder 的分步(步骤与德尔福)

Simply change the Icon in your apps resource file (say your app project is called ConsoleApp.dpr, your app resource file will be ConsoleApp.res)

The main icon resource in there is intuatively called MAINICON, just replace it.

Here is a step by step for C++ Builder (the steps are basically the same in Delphi)

山人契 2024-08-15 13:15:14
  1. 添加 {$R *.res}
  2. DPR 文件注释 {$APPTYPE CONSOLE} 行中
  3. 在 DPR 文件编辑项目 -> 的 选项->应用-> 图标
  4. 取消 DPR 文件中的

{$APPTYPE CONSOLE} 行的注释使用 Delphi XE 进行测试

  1. add {$R *.res} in your DPR file
  2. comment {$APPTYPE CONSOLE} line in your DPR file
  3. edit Project -> Options -> Application -> Icon
  4. uncomment {$APPTYPE CONSOLE} line in your DPR file

Tested with Delphi XE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文