Share via

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

youki 1,026 Reputation points
2024-01-20T12:01:43.6833333+00:00

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 development | Windows App SDK
Windows development | Windows API - Win32
Developer technologies | C++
Developer technologies | C++

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.


1 answer

Sort by: Most helpful
  1. Castorix31 91,876 Reputation points
    2024-01-20T14:30:04.0333333+00:00

    SaveIconToFile from https://github.com/Skight/wndspy/blob/b89cc2df88ca3e58b26be491814008aaf6f11122/Source/Contrib/SaveIcon.cpp works for me (tested on Jumbo icon of Notepad (SHGetFileInfo with SHGFI_SYSICONINDEX + SHGetImageList with SHIL_JUMBO )

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.