Public Group

# [C++]Setting icon for an exe

This topic is 2596 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

I just wondered how to choose an icon for my compiled exe? I've got an application which I use normally use to replace icons, but these doesn't even work because my app hasn't even got a single icon. It's just that white box windows displays when somethings is wrong (missing files, etc..). How can I use an icon for my exe? I need it not to be updated at runtime, I just want to compile with icons. I'm using Visual C++ Studio 2010, regular c++ project (no form). Thanks!

##### Share on other sites
Provided nothing has changed since I first learned about it (which was admittedly in the Win98 era), the icon used for the application is simply the icon with the lowest ID included in the executable's resource table.

##### Share on other sites
Provided nothing has changed since I first learned about it (which was admittedly in the Win98 era), the icon used for the application is simply the icon with the lowest ID included in the executable's resource table. [/quote]

Seems quite simple, but how do I use resources anyway? Didn't use them till know, and I checked the internet, but couldn't find much useful information. I tried right-clicking on my project and move over add, but then all I can do is add a class as "resource" is greyed out. Any idea? I'm using visual c++ studio 2010 express, maybe express can't handle resources (which I don't really think)..?

##### Share on other sites
Under 2008 its Project >> Add Existing Item (Or Project >> Add New Item >> Icon for new blank one)

##### Share on other sites
Thanks, I tried it out. First I added the icon itself with Add Existing item and compiled. Didn't work. Then I noticed visual studio created a .rc file but didn't include in my project. I added it with Add Existing item, and studio told me that I can't edit resources with Visual studio express SKU. Seems that I need the professional edition to do so :/ Or is there any way around?

##### Share on other sites

Seems quite simple, but how do I use resources anyway? Didn't use them till know, and I checked the internet, but couldn't find much useful information. I tried right-clicking on my project and move over add, but then all I can do is add a class as "resource" is greyed out. Any idea? I'm using visual c++ studio 2010 express, maybe express can't handle resources (which I don't really think)..?

Yep, doesn't work to add resources in the express version. You will get icons added to the project only if you create a win32 project. However you can add some files manually to have icons in your project:

resource.h
 #define IDI_PROJECTNAME 107 #define IDI_SMALL 108 

projectname.rc (this is the file responsible for creating your resource table, will be automatically compiled, you don't need to include it anywhere)
 #include "windows.h" #include "resource.h" IDI_PROJECTNAME ICON "projectname.ico" IDI_SMALL ICON "small.ico" 

projectname.ico (size should be 48x48)
small.ico (size should be 16x16)

Just replace "projectname" with your own project name.

• 47
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631373
• Total Posts
2999645
×