Shortcut Icon same as application icon

I have a compiled Win32 app that uses a .ico resource file, declared in the .cpp file. My icon displays fine in the application when running. How can I automatically have that same icon as a desktop shortcut, when the user creates a shortcut to the .exe file? Currently, it uses a default icon.
What do you mean with "ico resource file, declared in the .cpp file" ??? 🤔

If you want your EXE to have a proper icon, then you need to embed the desired .ico file as a resource into the EXE file!

https://learn.microsoft.com/en-us/windows/win32/menurc/resources-overviews

If you use Microsoft Visual C++, then simply create an .rc file like below and add it to your project:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#define APSTUDIO_READONLY_SYMBOLS
#include "WinResrc.h"
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
//
// Neutral resources
//
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
101 ICON "your_icon.ico"


Once you have done this, your EXE file should show up with the desired icon in Windows Explorer and friends.

Also, if the EXE has a proper icon, shortcuts will automatically use that icon by default...


As an aside, I highly recommend to have a look at Resource Hacker, when dealing with resources in EXE/DLL files:
http://www.angusj.com/resourcehacker/
Last edited on
I think you can direct the shortcut to the icon, or the file where it lives (can be dll, exe, other) manually in the configure shortcut area, but that may be a lot to ask most users. You can provide a preconfigured shortcut in the installer to do that for them, but better, fix it as above so it just works.
Last edited on
Topic archived. No new replies allowed.