Adding icon to .exe - c++

Hi people I been trying to do this the whole night, can somebody help me/guide me on this.
Details:
Not Visual Studio (using Geany).
I'm using A lightweight IDE, and projects option is not available.
Is for the .exe file output.
Please give me some guidance on this.

I use Resource Hacker for such tasks. This will add an existing icon to an EXE; you'll need another tool to make the actual icon.

I am guessing you are using Visual Studio since you are talking about Windows.
First go to "Resource View" (from menu: View → Other Window → Resource View). Then in "Resource View" navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon.
Recompile your project and see if change takes effect.
Second way:
Use preprocessor directives in your resource script to choose your icon file.

You need to use the resource compiler rc.exe. You will also need to create a .rc file listing the resource (your icon). On compilation with rc.exe, you will get a .res file which should be passed to the linker.

Related

Which attach to process should I choose for visual studio 2017?

I'm not sure which one should I pick.
Visual Studio is trying to find an instance of the program that matches the cpp file you opened to debug the program. Not what you want to do.
You need to create a Visual Studio project to manage the program you're going to build. Select File->New->Project
From the Dialog that brings up, Track down and expand Visual C++ in the tree structure on the left. Look for and select Win32. Click Win32 Console Project from the pane in the middle. Name the project appropriately and place it somewhere on the hard drive where you can find it easily later. Click OK.
Now you get the Application Wizard. Click Next. Uncheck Precompiled Header. You probably don't care about the SDL checks either, but they won't give you the kinds of grief the Precompiled Headers will at this stage of your career. I don't think anyone really knows why Precompiled Headers are on by default, but by the time you need them, you know what they are and how to take advantage of them. A one file program doesn't need them and leaving them on will give you a bunch of errors. Click Finish.
Select all of the code in the editor. Paste the code provided by the instructor over top of it.
To build and run the program click the green Play button.

Console cpp project in Visual Studio

What and how should I install in order to be able to create an ordinary console project in Visual Studio?
Here is what I have already installed and what options I have. The problem is that there is no option for creating an ordinary console project. Is it named somewhat different not just a console project in cpp?
Look under the "Installed" tab on the left side, not the "Online" tab you currently selected. You should find "Win32 Console Application" there.
I recommend to use 'Empty project' option for such purposes. Just type 'Empty' in the search field to find it.
In this case you have to manually add .cpp file, define a main function - and you will have simple console application with no Windows-specific overheads.

How to assign an icon to an executable on windows (or visual studio) [duplicate]

This question already has answers here:
How do I set the icon for my application in visual studio 2008?
(6 answers)
Closed 9 years ago.
I would like to use a custom icon (a .ico file) for an executable, on windows (XP).
The executable is a C++ program created thanks to visual studio (2008).
How can I change the icon from the executable, to the .ico file I want?
Has mentioned in the comment, it is a duplicate question
Here is a copy paste of the answer from Jason Stevenson:
First go to Resource View (from menu: View --> Other Window --> Resource View). Then in Resource View navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon.
Use the embedded image editor in order to edit the existing or new icon. Note that an icon can include several types (sizes), selected from Image menu.
Then compile your project and see the effect.
You can use a program such as Resource Hacker to edit resources (including icons) of Windows executables.
Assuming you have a "resource.h" and a ".rc"-file ,you define a identifier in "resource.h" (lets call it IDI_MY_ICON) and then add a line in the icon-section of your rc-file like IDI_MY_ICON ICON "myicon.ico" as the first icon (thus this line must preceed any other ICON lines). Rebuild ,that's it.
In C# projects you right clink on project that creates .exe file, select Properties and on the first screen you can set icon. Not sure if this works for C++ but the properties panel is the place that you should look in.
You should be able find it at the 'Properties' of your project. (By rightclicking your project name). It's on the Application Tab, at least, in Visual Studio 2008 working in C# it is, and scrolling down there a bit.

MFC - Replacing default application icon

I have a MFC Dialog Application. I would like to replace the application exe icon.
I open the default MFC icon eg. app.ico in the res folder using Axialis IconWorkshop.
Replace all images in the icon.
Save it to appA.ico.
Then I change Filename property of icon IDR_MAINFRAME to res\appA.ico.
Visual Studio icon editor shows the correct image.
But when I build the application, the icon associated to the app.exe still show MFC default icon.
What went wrong?
In these cases the Visual Studio designer is a little buggy (or, otherwise, by design but incomprehensible). It's best to edit the .rc code file and change the icon filename there.
I think I recall that it is the first icon in the .RC file that is used, no matter what you do, so you might have to edit the .RC file directly, like djeidot says.
Sometimes, Windows caches icons. It may not be a problem with your application. Try downloading something like Resource Hacker
and look at your exe file. If the icon looks right, there is an IconCache.db or similar in your appdata\Local folder (depending on Windows version). Delete that and reload Explorer.
One of the Visual Studio files caches some resources; unfortunately I can't remember which one at the moment. Rename those files with odd extensions to something else and try a rebuild.
I have same problem and solve it by this solution:
Build\Clean Solution
Copy appA.ico again into res folder
Rebuild project
I have same problem and solve it by :
1.clear solution
2.open task manager and goto details tab.
3.search for explorer.exe and right click on it and end task.
4.goto File->run new task, type explorer.exe
5.now build the solution and check application icon.

Setting file version number in Visual Studio 2005 C++

Can anyone point me in the right direction how to configure Visual Studio 2005 with our C++ console project how we can include a 'File Version' in the details section of the file properties.
I've tried resource files without any luck. This is with a C++ project just for clarification, and big thank you for the guys you responded with C# suggestions.
Thanks in advance.
If you are talking about unmanaged c++, you need to add a version resource to the project.
right-click on the project, choose add - Resource.... Choose Version and press new.
There you can enter all info you need.
You have to have one VS_VERSION_INFO section in your resource (*.rc) file(s) that compile into your project.
In the Visual Studio 2005 Solution Explorer, open the context menu on your C++ project and choose Add, Resource.
Mark Version and click "New".
Fill in the fields as desired and save the file.
Build.
Now your project output has a FileInfo resource.
Please be aware that Windows Vista does not show all available version info in the Explorer context menu's "Details" tab.
For c++ projects I use StampVer and call it as a post build operation including check in/out of revision control for release builds.
Unless you have a good reason for your file version to be different than the version of the assembly inside, I think it is a better idea to provide the AssemblyVersion alone. If you do not specify an AssemblyFileVersion, it will automatically get the same value, so you can see your assembly's version directly in the file's properties.
The advantage is that you can use a wildcard and allow the version to be automatically incremented, so that every time you compile the library you get a different build and/or revision number. As far as I can tell, this trick does not work with AssemblyFileVersion, so you have to increment it by hand.
Of course, all this only applies if you're writing .NET code. Are you by any chance talking about a project using unmanaged code?