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

youki 1,021 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++
{count} votes

1 answer

Sort by: Most helpful
  1. Castorix31 90,521 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 )


Your answer

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