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.
*/
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)
+ {
+ hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
+ }
+ else
{
- if (m_pPidl)
- hr = SHELL_PidlGetIconLocationW(m_pPidl, uFlags, pszIconFile, cchMax, piIndex, pwFlags);
+ *pwFlags = GIL_NOTFILENAME | GIL_PERCLASS;
}
return hr;
*/
// 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)
{