[0.4.9][SHELL32] Update CShellLink::GetIconLocation() & CShellLink::Extract()

to the state of 0.4.10-release-24-g8c2fc27 to fix
regression CORE-14009 "blank icons in livecd for desktop-lnk cmd & QuickLaunch"
which regressed by 0.4.7-dev-111-g d800840 == SVN r75607

The most relevant part came from 0.4.11-dev-11-g 6eb6aa2 which I ported back earlier already into 0.4.10-RC-13-g 3a1fe9d

(and this fixes/prevents also another regression CORE-14961 which did affect only intermediate states, in other words
was never present in releases/0.4.7 0.4.8 and 0.4.9)
This commit is contained in:
Joachim Henze 2020-11-29 23:00:36 +01:00
parent 7ceae3fc62
commit ead395d3ae

View file

@ -1714,6 +1714,9 @@ static HRESULT SHELL_PidlGetIconLocationW(PCIDLIST_ABSOLUTE pidl,
HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation(UINT uFlags, PWSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
{
HRESULT hr;
pszIconFile[0] = UNICODE_NULL;
/*
* It is possible for a shell link to point to another shell link,
* and in particular there is the possibility to point to itself.
@ -1732,42 +1735,61 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation(UINT uFlags, PWSTR pszIcon
*/
uFlags |= GIL_FORSHORTCUT;
if (m_pPidl || m_sPath)
if (uFlags & GIL_DEFAULTICON)
return E_FAIL;
hr = GetIconLocation(pszIconFile, cchMax, piIndex);
if (FAILED(hr) || pszIconFile[0] == UNICODE_NULL)
{
/* first look for an icon using the PIDL (if present) */
if (m_pPidl)
hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
else
hr = E_FAIL;
#if 0 // FIXME: Analyse further whether this is needed...
/* if we couldn't find an icon yet, look for it using the file system path */
if (FAILED(hr) && m_sPath)
{
LPITEMIDLIST pidl;
CComPtr<IShellFolder> pdsk;
hr = SHGetDesktopFolder(&pdsk);
/* LPITEMIDLIST pidl = ILCreateFromPathW(sPath); */
hr = pdsk->ParseDisplayName(0, NULL, m_sPath, NULL, &pidl, NULL);
if (SUCCEEDED(hr))
{
hr = SHELL_PidlGetIconLocationW(pidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
SHFree(pidl);
}
}
#endif
return hr;
hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
}
else
{
*pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
}
return S_OK;
return hr;
}
HRESULT STDMETHODCALLTYPE CShellLink::Extract(PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
HRESULT STDMETHODCALLTYPE
CShellLink::Extract(PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
{
UNIMPLEMENTED;
return E_FAIL;
HRESULT hr = NOERROR;
UINT cxyLarge = LOWORD(nIconSize), cxySmall = HIWORD(nIconSize);
if (phiconLarge)
{
*phiconLarge = NULL;
PrivateExtractIconsW(pszFile, nIconIndex, cxyLarge, cxyLarge, phiconLarge, NULL, 1, 0);
if (*phiconLarge == NULL)
hr = S_FALSE;
}
if (phiconSmall)
{
*phiconSmall = NULL;
PrivateExtractIconsW(pszFile, nIconIndex, cxySmall, cxySmall, phiconSmall, NULL, 1, 0);
if (*phiconSmall == NULL)
hr = S_FALSE;
}
if (hr == S_FALSE)
{
if (phiconLarge && *phiconLarge)
{
DestroyIcon(*phiconLarge);
*phiconLarge = NULL;
}
if (phiconSmall && *phiconSmall)
{
DestroyIcon(*phiconSmall);
*phiconSmall = NULL;
}
}
return hr;
}
#if 0