I want to load the icon of an .exe in a CImage object, in order to easily display and save it in a database. My problem is that I have an HICON and I seem to only be able to load/attach an HBITMAP to a CImage object.
SHFILEINFO sfi;
Cimage icon;
DWORD ret = SHGetFileInfo(path, 0, &sfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME);
if(ret != 0) {
// copy info
hIcon = sfi.hIcon;
if(hIcon != lastHIcon && hIcon != 0) {
// This does not work, needs a HBITMAP instead of a HICON
icon.Attach(hIcon);
}
}
Is there any easy method of doing this, or do I need to render the HICON to a DC first? It just seems to me that there should be a solution that does not require me to be a GDI expert.