How can I change the default .exe icon in Visual Studio 2012 (C++)

19,875

Solution 1

Adding icon to executable

Tested for VS2012 Express

Create a icon.rc file next to your .vcxproj file and fill it with the following text:

// Icon Resource Definition
#define MAIN_ICON                       102
MAIN_ICON               ICON                    "your_icon.ico"

Then add the following to your .vcxproj file anywhere within the Project tag:

<ItemGroup>
    <ResourceCompile Include="icon.rc">
    </ResourceCompile>
</ItemGroup>

Additional options

If you want you may forward definitions to your icon.rc file like so:

<ItemGroup>
    <ResourceCompile Include="icon.rc">
        <AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">/D_DEBUG %(AdditionalOptions)</AdditionalOptions>
    </ResourceCompile>
</ItemGroup>

Notice the /D_DEBUG definition, which defines _DEBUG for your resource file. Then within your icon.rc file check for definitions normally:

#define MAIN_ICON 102
#if defined(_DEBUG)
MAIN_ICON               ICON                    "debug_icon.ico"
#else
MAIN_ICON               ICON                    "release_icon.ico"
#endif

Solution 2

  1. Add an icon in the resource section of you C++ project. This icon will be shown as an Application icon for your executable. [Note: make sure you are in the Resource View window, not the Solution Explorer window. Then right-click on the rc folder to Add Resource...]

  2. I have tried this with Win32 Console Application and it shows the icon in the Explorer as Application Icon. This should work with other types of applications also.

  3. Also note that while adding the icon you need to add different size images for the Icon like 16*16, 32*32. These different icon images will be used by Windows Explorer to display Application Icon in different View Modes(Small Icons, Medium Icons, Larget Icons, Extra Large icons etc.)

Solution 3

This is not really how it works. The size of the icon of your program as displayed by Windows isn't determined by you, the user selects it. It is a user preference, very simple to change on later Windows versions by just rolling the mouse scroll button on the desktop. And an icon doesn't have just a single size, it is capable of storing multiple images. Windows picks the one that fits best. And the one you get when starting a new project is just a stock one that's stored in the project template. You can change it by tinkering with the project template .zip file but that's kinda pointless, you want to give your program a custom icon that personalizes it.

Best thing to do is to steal, beg or borrow one, making a good looking icon is an art. Lots of web sites where you can download free ones. If you want to take a shot at creating your own then that's supported as well. Simply double-click the project's .rc file to open the resource view, open the Icon node and double-click the default icon to open the icon editor. You add a new size with Image + New Image Type. Plenty of freeware icon editors available as well.

Share:
19,875
Garrett Ratliff
Author by

Garrett Ratliff

Updated on June 07, 2022

Comments

  • Garrett Ratliff
    Garrett Ratliff over 1 year

    I was wondering if there was a way to change the default icon that VS2012 makes when I compile my app. Just for those wondering, I am trying to change the .exe program's icon, not the window icon at the top left of the window and on the start menu. I already know how to do that. I have been Google-ing this for ever and it always shows up how to change the window icon, not the actual file's icon. Thanks in advance!!!

    EDIT: This is what I want to do...

    I want to replace this...

    enter image description here

    with this...

    enter image description here]

    Thanks, hope this clarifies.