Extract high resolution icon or thumbnail for file Extract high resolution icon or thumbnail for file windows windows

Extract high resolution icon or thumbnail for file


If you are targeting Vista and higher, you can get a 256x256 icon from the jumbo image list. If you need to target XP, you can at least use the extra large image list, which is 48x48 (slightly better than 32x32 large).

#include <commoncontrols.h>#include <shellapi.h>HICON GetHighResolutionIcon(LPTSTR pszPath){    // Get the image list index of the icon    SHFILEINFO sfi;    if (!SHGetFileInfo(pszPath, 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX)) return NULL;    // Get the jumbo image list    IImageList *piml;    if (FAILED(SHGetImageList(SHIL_JUMBO, IID_PPV_ARGS(&piml))) return NULL;    // Extract an icon    HICON hico;    piml->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hico);    // Clean up    piml->Release();    // Return the icon    return hico;}


Have you tried ExtractIconEx()?

It has dedicated parameters to extract arrays of both small and large icons from executables, DLLs, or icon files. From there you can select the size best suited to your needs. The API call is available from Win2K onwards.