How to extract an icon from executable and save it on disk properly? Any lightweight library?

youki 991 Reputation points

Is there something in c++? (Windows API/ WinRT) I've tried some solutions online and none of them work. I didn't find anything useful on Github either. I want to display the icons regardless of whether the exe is still there, so I want to save the icon; only 1 size is enough. (I think the difficult part is saving the HIcon, I can't find anything about the process.)

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
693 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,352 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,441 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 80,906 Reputation points

    SaveIconToFile from works for me (tested on Jumbo icon of Notepad (SHGetFileInfo with SHGFI_SYSICONINDEX + SHGetImageList with SHIL_JUMBO )