Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 668
Garrett Ratliff Avatar asked Feb 17 '23 19:02

Garrett Ratliff


1 Answers

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
like image 132
Sergio Basurco Avatar answered Feb 19 '23 10:02

Sergio Basurco