[SHELL32] Fix CShellLink::GetIconLocation (#810)

Fixes a regression from PR #784.
CORE-14961

cherry-picked from commit 0.4.11-dev-11-g
6eb6aa2895
This commit is contained in:
Katayama Hirofumi MZ 2018-08-26 22:37:15 +09:00 committed by Joachim Henze
parent 1194b0b9c7
commit 3a1fe9d044

View file

@ -1721,6 +1721,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.
@ -1739,11 +1742,17 @@ HRESULT STDMETHODCALLTYPE CShellLink::GetIconLocation(UINT uFlags, PWSTR pszIcon
*/
uFlags |= GIL_FORSHORTCUT;
if (uFlags & GIL_DEFAULTICON)
return E_FAIL;
hr = GetIconLocation(pszIconFile, cchMax, piIndex);
if (FAILED(hr))
if (FAILED(hr) || pszIconFile[0] == UNICODE_NULL)
{
if (m_pPidl)
hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
}
else
{
*pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
}
return hr;
@ -1888,13 +1897,14 @@ HRESULT STDMETHODCALLTYPE CShellLink::SetIconLocation(LPCWSTR pszIconPath, INT i
*/
// FIXME: http://stackoverflow.com/questions/2976489/ishelllinkseticonlocation-translates-my-icon-path-into-program-files-which-i
// if (PathFullyUnExpandEnvStringsW(pszIconPath, szUnExpIconPath, _countof(szUnExpIconPath)))
SHExpandEnvironmentStringsW(pszIconPath, szUnExpIconPath, _countof(szUnExpIconPath));
PathUnExpandEnvStringsW(pszIconPath, szUnExpIconPath, _countof(szUnExpIconPath));
if (wcscmp(pszIconPath, szUnExpIconPath) != 0)
{
/* Unexpansion succeeded, so we need an icon environment block */
EXP_SZ_LINK buffer;
LPEXP_SZ_LINK pInfo;
pszIconPath = szUnExpIconPath;
pInfo = (LPEXP_SZ_LINK)SHFindDataBlock(m_pDBList, EXP_SZ_ICON_SIG);
if (pInfo)
{