Ejemplo n.º 1
0
HICON GetHighResolutionIcon(LPTSTR pszPath)
{
    // Get the image list index of the icon
    SHFILEINFO sfi;

    if (!SHGetFileInfo(pszPath, -1, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_ICON | SHGFI_LARGEICON))
    {
        return NULL;
    }

    // Get the jumbo image list
    IImageList *piml;

    if (DEFAULT_ICOH_SIZE_WIDHT == 32)
    {
        if (FAILED(SHGetImageList(SHIL_LARGE, IID_IImageList, (void **)(&piml))))
        {
            return NULL;
        }
    }
    else  // 48
    {
        if (FAILED(SHGetImageList(SHIL_EXTRALARGE, IID_IImageList, (void **)(&piml))))
        {
            return NULL;
        }
    }


    // Extract an icon
    HICON hico;
    piml->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hico);

    int w, h;
    piml->GetIconSize(&w, &h);

    // Clean up
    piml->Release();

    // Return the icon
    return hico;
}