1

I am using Visual Studio and C++ to create a console app. I want the exe file to have a custom icon instead of the default windows icon.

Icon

Scheff's Cat
  • 19,528
  • 6
  • 28
  • 56
Bob8552
  • 23
  • 5
  • Check this: https://stackoverflow.com/questions/1170383/c-sharp-console-application-icon – Nandostyle Jun 30 '20 at 16:19
  • "Is there any way I can give my app an icon?" - Yes. Many applications have managed this in the past. It most certainly is possible. What is your *specific* question related to achieving this? Where are you stuck? What have you tried? What does your code look like? – Jesper Juhl Jun 30 '20 at 16:21
  • @Nandostyle That other question is about managed C# projects. – dxiv Jun 30 '20 at 16:44
  • But the procedure in Visual Studio should be the same. – Nandostyle Jun 30 '20 at 16:45
  • @Nandostyle But unfortunately, is not. – Ted Lyngmo Jun 30 '20 at 16:46
  • @Nandostyle No, that's a compiler option for [vbc.exe](https://learn.microsoft.com/en-us/dotnet/visual-basic/reference/command-line-compiler/win32icon) (VB) and [csc.exe](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/win32icon-compiler-option) (C#), so it is language specific and there is no such option for the C++ compiler. – dxiv Jun 30 '20 at 16:48
  • I stand corrected, I though C++ had that compiler option. – Nandostyle Jun 30 '20 at 16:49
  • Check this out: https://www.daniweb.com/programming/software-development/threads/121245/how-to-change-icon-of-c-console-app – Nandostyle Jun 30 '20 at 16:53
  • Does this answer your question? [C# console application icon](https://stackoverflow.com/questions/1170383/c-sharp-console-application-icon) – Ali Kianoor Jun 30 '20 at 17:47

2 Answers2

2

You need to create .rc file (e.g. application.rc) and add it to the Visual Studio project:

IDI_APPLICATION    ICON    "application.ico"

with the relative path to the .ico file (just the file name if the icon file is in the same directory with .rc file, or use forward slash in path if it is in a subdirectory, e.g. "resources/application.ico").

dewaffled
  • 2,850
  • 2
  • 17
  • 30
  • I can confirm that this is working - and the `/win32icon` option does _not_ work in MSVC if anyone is trying that out. – Ted Lyngmo Jun 30 '20 at 16:37
  • @TedLyngmo `/win32icon` is for VB/C# projects. – dxiv Jun 30 '20 at 16:43
  • 1
    @dxiv Yes, but the article linked to in the comments mentioned it, so I had to look it up to figure that out. Just thought it would save someone some time :-) – Ted Lyngmo Jun 30 '20 at 16:45
0

You could right click your project and select add->resource->Icon->import, then you could import your icon. Because the Windows shell - normally Explorer - will use the icon with lowest ID or name as the default icon. So, you could check if the ID of the icon is the lowest. If not, you could change it.

Also, you could refer to this link .

Barrnet Chou
  • 1,738
  • 1
  • 4
  • 7