How to change the default *.exe icon in C/C++? - c++

I want to change the default .exe icon to some other icon in C/C++. Does anybody know how to do that?

Already answered.
Change app icon in Visual Studio 2005?
You have to place your .ico file in the resources folder first of course.

Use this one: http://www.angusj.com/resourcehacker/
Since you specified that you are using VS2008 I can point you here: How do I set the icon for my application in visual studio 2008? (duplicate question)

On Windows, if the executable contains many icons, the 1st of them will be the default.
If you have icons resource in your programming environment, place the icon you want first in the list.
Edit: since you created an empty project, to add an icon, follow these instructions:
(as I said in my comment, I don't have VS2008, but the steps should be the same)
Menu: Insert -> Resource -> Import
Select "Icon", press the import button and select your icon file.
Now, close the icon editor, and save the resource script in the project folder.
Select "Files View" and add the resource script file in the "Resource Files".
That's it.

if you are using any ide like dev c++, then you can specify the icon you want to appear on your file in project options

Related

An analog for Qt resource files?

I need something similar to the resource system that Qt has.
Instead of writing the full path to the files and dragging them with the program, I would like to create a single file like Qt does and enter relative file paths.
I can't use Qt in my project, and using the. rc files that Visual Studio provides is very complex and cumbersome.
What can I use instead?
You might need the .resx Resource Files.
A way to create this is to open Visual Studio:
Right-click your project
Select Add | New Item
Select Resources File
Give it a name (e.g. Resources)
Click Add
You will now have a Resources file in your project with the name you provided, and it should auto-open the resources editor. If it doesn't, double-click it in the project.
In the top-left of the editor, click the "Strings v" drop down and select "Icons".
Drag your icon into this screen.
Rename it to whatever you want (e.g. something).
If you familiar with the QT Resource files you will get to use it in no time.
Source: How to create resx files
Brief doc: https://learn.microsoft.com/en-us/dotnet/framework/resources/creating-resource-files-for-desktop-apps
https://learn.microsoft.com/en-us/dotnet/framework/resources/working-with-resx-files-programmatically

How to specify an application icon for C++ Visual Studio 2019?

I've seen this documentation for C#/Visual Basic application icons, but there is nothing I can find for how to do this with the C++ version.
This StackOverflow question is for Visual Studio 2008, not 2019. This one is also obsolete, as it works for Visual Studio 2017 but not Visual Studio 2019.
After some fiddling I figured it out. This answer for VS2017 was basically correct, but it didn't fully explain what you have to do to get it to work and the documentation it links to was vague enough to confuse me, so I'll post this answer as the VS2019 version with full and complete easy-to-follow instructions.
Navigate to your Solution Explorer tab.
Find the Resource Files folder in your project, probably near your Header Files and Source Files folders.
Right-click on the Resource Files folder and select "Add > Resource."
In the "Add Resource" window that pops up, select Icon and select Import.
Import either a bitmap file or your custom .ico file.
Now a Resource File (.rc) is created which contains your application Icon, in the form of an Icon node. Click on that .rc file to open the Resource View tab.
You'll see that there's a folder called Icon. It should contain your new icon.
If it contains a default Icon file, probably named IDI_ICON1, you'll have to edit that node to make it the icon you want to use. I don't know why it does that.

Can we change an exe icon according to the current solution configuration?

I want to know if there's a simple way to change my exe icon depending on compilation in release / debug / other configuration.
IDE is Visual Studio 2013, source code in C++.
Thanks in advance.
It may be possible using a combination of tricks.
Create an icon for each configuration and store them each in a folder with the same name as the configurations you use (like Debug, Release).
Use $(ConfigurationName) in a pre-build command line. Create a batch file to copy the correct icon to the 'source' location. In other words if the application icon is .\App.ico create a batch file: 'copy .\%1\App.ico .\App.ico' or similar. (obviously get the paths correct).
The batch will execute and overwrite the app icon with the custom build icon.
Change configuration and the icon can change. Just make sure that all icons are the same size.
I have used this to copy a text file into my builds - cannot see why it cannot work with icons.

exe icon is changing automatically when build the application in visual studio

I want to change my application exe icon from default. Now when I copied the new icon with same name as default icon had in "res" folder of application. when I compiled it's exe came with new icon.
But at the same time when I copied another icon with another name in "res" folder and include it in my project. Now rese folder has two icons(one icon is for application's icon). Now when I compiled my application that time exe come with new icon. But it should come with old icon as IDR_MAINFRAME holds.
Please help me out.
Thank You
you have to edit the .rc icon file directly. I think it's already write in duplicate post.

MFC logo in a MFC application

I have an MFC application. When the application is launched, I see it is represented on the taskbar using the MFC logo. Also, the application Window Menu Bar has the MFC icon.
How can I replace these with custom made logos?
The icons are in the .ico file that is part of your project. Usually in the /res directory. You can edit them or replace them with files you generate.
The icon file is stored with your project files.
Go to <Projects Folder>\SOLUTIONNAME\PROJECTNAME\res. When you locate this folder, there should be a PROJECTNAME.ico file. rename the ico file you created to PROJECTNAME.ico. Next time you build your project, the MFC icon should be replaced with your custom icon.
I recommend going to this site mostly because it does not require any registration and its 100% free.
You can then fine a suitable icon for your program bu searching keywords.
Then select the .ICO type and download.
Copy the .ico file to your “res” folder.
Then delete the .ico file and rename the downloaded file to .ico.