application icon

Adam D. Ruppe destructionator at gmail.com
Wed Mar 13 06:40:58 PDT 2013


On Wednesday, 13 March 2013 at 12:59:57 UTC, Gimsom wrote:
> Hi, I would like to set an icon for my D2 application but I have
> no idea how to do that, could somone explain me? Thanks.

Create the .ico file and put it in your project folder. Then make 
a resource file:

whatever_name.rc

with just one line of content:

IDI_ICON1       ICON    DISCARDABLE     "iconfil.ico"


Then, when you build the program, run rcc on this:

\dm\dm\bin\rcc.exe whatever_name.rc

rcc.exe is included in this download: 
http://ftp.digitalmars.com/bup.zip

It will make a .res file for you.

Then build the exe like so:

\dmd\windows\bin\dmd app.d whatever_name.res

and your exe should show the icon.




While you're at it, if you want to prevent the text console 
window from appearing when you run the program, you can make a 
file called "whatever_name.def" with these two lines:

EXETYPE NT
SUBSYSTEM WINDOWS


and then add it to the compile line too. So you end up with a 
build process of:

\dm\dm\bin\rcc.exe whatever_name.rc
\dmd\windows\bin\dmd app.d [also list your other .d files...] 
whatever_name.res whatever_name.def


and you have an exe together with icon and no console.


More information about the Digitalmars-d-learn mailing list