v2: -fix missing \n -return error on failure
To: wine-devel wine-devel@winehq.org
Fix for bug https://bugs.winehq.org/show_bug.cgi?id=45868
Signed-off-by: Louis Lenders xerox.xerox2000x@gmail.com --- dlls/shell32/iconcache.c | 25 ++++++++++++++++++++----- dlls/shell32/tests/shelllink.c | 8 ++++++++ 2 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c index 6107e0c33b..fb9881cf8f 100644 --- a/dlls/shell32/iconcache.c +++ b/dlls/shell32/iconcache.c @@ -1004,7 +1004,9 @@ INT WINAPI SHGetIconOverlayIndexW(LPCWSTR pszIconPath, INT iIconIndex) */ HRESULT WINAPI SHGetStockIconInfo(SHSTOCKICONID id, UINT flags, SHSTOCKICONINFO *sii) { - static const WCHAR shell32dll[] = {'\','s','h','e','l','l','3','2','.','d','l','l',0}; + static const WCHAR shell32dllW[] = {'s','h','e','l','l','3','2','.','d','l','l',0}; + static const WCHAR slashW[] = {'\',0}; + HMODULE hmod;
FIXME("(%d, 0x%x, %p) semi-stub\n", id, flags, sii); if ((id < 0) || (id >= SIID_MAX_ICONS) || !sii || (sii->cbSize != sizeof(SHSTOCKICONINFO))) { @@ -1015,14 +1017,27 @@ HRESULT WINAPI SHGetStockIconInfo(SHSTOCKICONID id, UINT flags, SHSTOCKICONINFO
/* no icons defined: use default */ sii->iIcon = -IDI_SHELL_FILE; - lstrcatW(sii->szPath, shell32dll); - - if (flags) - FIXME("flags 0x%x not implemented\n", flags); + lstrcatW(sii->szPath, slashW); + lstrcatW(sii->szPath, shell32dllW);
sii->hIcon = NULL; sii->iSysImageIndex = -1;
+ if (flags & SHGSI_ICON) + { + hmod = GetModuleHandleW(shell32dllW); + if (hmod) + sii->hIcon = LoadIconW(hmod, MAKEINTRESOURCEW(IDI_SHELL_FILE)); + + if (!sii->hIcon) + { + ERR("failed to get an icon handle\n"); + return E_FAIL; /*howto test?*/ + } + } + else + FIXME("flags 0x%x not implemented\n", flags); + TRACE("%3d: returning %s (%d)\n", id, debugstr_w(sii->szPath), sii->iIcon);
return S_OK; diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c index 65e9a6dd55..547ebfd86a 100644 --- a/dlls/shell32/tests/shelllink.c +++ b/dlls/shell32/tests/shelllink.c @@ -1112,6 +1112,14 @@ static void test_SHGetStockIconInfo(void) /* there is a NULL check for the struct */ hr = pSHGetStockIconInfo(SIID_FOLDER, SHGSI_ICONLOCATION, NULL); ok(hr == E_INVALIDARG, "NULL: got 0x%x\n", hr); + + memset(buffer, 0, sizeof(buffer)); + sii->cbSize = sizeof(SHSTOCKICONINFO); + hr = pSHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, sii); + ok(hr == S_OK, "got 0x%x (expected S_OK)\n", hr); + ok(sii->hIcon != NULL, "got NULL, expected an icon handle\n"); + ok(sii->iSysImageIndex == -1, "got %d (expected -1)\n", sii->iSysImageIndex); + ok(DestroyIcon(sii->hIcon), "DestroyIcon failed\n"); }
static void test_SHExtractIcons(void)
Louis Lenders xerox.xerox2000x@gmail.com writes:
- if (flags & SHGSI_ICON)
- {
hmod = GetModuleHandleW(shell32dllW);
if (hmod)
sii->hIcon = LoadIconW(hmod, MAKEINTRESOURCEW(IDI_SHELL_FILE));
Now that we have a bunch of icons, it shouldn't be hard to return them instead of hardcoding IDI_SHELL_FILE.