Try to lookup icon information from shell32.dll. If an icon is not found, default to the file icon.
Instead of defaulting to -1, which was failing for Affinity Photo's installer.
-- v3: shell32: Try to lookup icon, with fallback on failure
From: James McDonnell topgamer7@gmail.com
Try to lookup icon information from shell32.dll. If an icon is not found, default to the file icon.
Instead of defaulting to -1, which was failing for Affinity Photo's installer. --- dlls/shell32/iconcache.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index 8f9519d2ca8..055b48de496 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -1000,19 +1000,24 @@ HRESULT WINAPI SHGetStockIconInfo(SHSTOCKICONID id, UINT flags, SHSTOCKICONINFO
GetSystemDirectoryW(sii->szPath, MAX_PATH);
- /* no icons defined: use default */ - sii->iIcon = -IDI_SHELL_FILE; + sii->iIcon = id; lstrcatW(sii->szPath, L"\shell32.dll");
- if (flags) - FIXME("flags 0x%x not implemented\n", flags); + if (flags & ~SHGSI_ICON) + FIXME("unhandled flags 0x%x\n", flags);
sii->hIcon = NULL; - if (flags & SHGSI_ICON) - sii->hIcon = LoadIconW(GetModuleHandleW(sii->szPath), MAKEINTRESOURCEW(sii->iIcon)); + if (flags & SHGSI_ICON) { + sii->hIcon = LoadIconW(GetModuleHandleW(sii->szPath), MAKEINTRESOURCEW(id)); + if (!sii->hIcon) { + FIXME("Could not find StockIcon, using placeholder\n"); + sii->iIcon = SIID_DOCASSOC; + sii->hIcon = LoadIconW(GetModuleHandleW(sii->szPath), MAKEINTRESOURCEW(sii->iIcon)); + } + } sii->iSysImageIndex = -1;
- TRACE("%3d: returning %s (%d)\n", id, debugstr_w(sii->szPath), sii->iIcon); + TRACE("%3d: returning %s (%d), icon handle=%p\n", id, debugstr_w(sii->szPath), sii->iIcon, sii->hIcon);
return S_OK; }
This would need some kind of lookup table, the resource ids don't quite match the SHSTOCKICONID enum.
Would it be more reasonable to just change the default id it uses? Right now it is `-IDI_SHELL_FILE`, which returns 0 for hIcon. If I change it to `IDI_SHELL_FILE` hIcon gets a proper value.