Link to home
Start Free TrialLog in
Avatar of Cyber-Dragon
Cyber-Dragon

asked on

C++ Give Executable File An Icon

I'm making a program in C++ thats just an exe file but the Windows default icon looks rather boring. Is there some way to code the icon into the program without requiring extra files to go with the exe?
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

The icon and be added as an embedded resource. How this is done depends on what type of application you are developing. Is it an MFC, WinForms, WPF, Win32? Each of these will have different mechanisms for doing this.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cyber-Dragon
Cyber-Dragon

ASKER

Sorry for the delay.

I'm making a Windows application from scratch.

jkr, with the solution you gave me will I have to move the ico file with my executable?
No, not necessary. Dureing the build process (while the resource compiler processes the .tc file), it'll be embedded into the executable. See e.g. http://msdn.microsoft.com/en-us/library/aa381018(VS.85).aspx ("Icon Resource")
And this can be defined anywhere in the program?
No, you need to put that into a separate file with an .rc extension which you add to you project. These files can not only contain icons, but also, bitmaps, string tables etc., see http://msdn.microsoft.com/en-us/library/aa380599.aspx ("About Resource Files")
I created a .rc file with notepad, put the code into it and put the icon file in the folder. But now when I compile, the executable is not in the release or debug folders.
Any build errors in the oputput window? And, more important: Have you added the .rc file to your solution?
No build errors and yes I did.

1>Compiling resources...
OK, that seems allright. Could you post the whole BuildLog?
Its ok I figured out what I was doing wrong.

I was in the wrong folder.

The project has two sets of Realese and Debug folders and I was in the one to deep.
Read the entire post on instructions on how to create the .rc file.