|
|
|
date: Mon, 4 Feb 2008 15:41:06 -0800,
group: microsoft.public.platformsdk.shell
back
RE: IShellIcon::GetIconOf
This is my very simple set of code to Support IShellIcon.
- I can confirm that it is getting called.
- I can confirm that it is returning S_OK when it sets the Icon and S_FALSE
when it doesn't
- I can confirm that an icon is showing up -- however it is not the right
icon based on the documentation in MSDN. Icons show -- they are valid icons,
however they are not default folders, open folders, and applications.
If need I can provide a screen shot of the icons. What it appears like is
that DefView is modifying the system icon list, and using the default icon
indexs in the MSDN documentation is reference the wrong icons.
-Wayne
STDMETHODIMP CShellFolder::GetIconOf(LPCITEMIDLIST pidl, UINT flags, LPINT
lpIconIndex)
{
HRESULT hrReturn = S_OK;
BSTR bstrName = NULL;
LPTSTR szExtension = NULL;
// WWB: When a client sets the GIL_ASYNC flag in uFlags and receives
E_PENDING as a return value,
// it typically creates a background thread to extract the icon.
if (flags & GIL_ASYNC)
{
hrReturn = E_PENDING;
goto End;
}
LPMYPIDLDATA pData = m_pPidlMgr->GetDataPointer(pidl);
if (!pData)
{
// WWB: TODO Handle Error
hrReturn = E_FAIL;
goto End;
}
switch(pData->pidlType)
{
case PT_FILE:
hrReturn = FileGetName(pData->guid,&bstrName);
if (FAILED(hrReturn))
{
// WWB: TODO Handle Error
goto End;
}
hrReturn = ::GetExtension(bstrName,&szExtension);
if (FAILED(hrReturn))
{
// WWB: TODO Handle Error
goto End;
}
if ((!_tcsicmp(szExtension,_T(".exe"))) ||
(!_tcsicmp(szExtension,_T(".bat"))) ||
(!_tcsicmp(szExtension,_T(".com"))))
{
*lpIconIndex = 2;
goto End;
}
hrReturn = S_FALSE;
break;
case PT_FOLDER:
switch(flags)
{
case 0:
*lpIconIndex = 3;
break;
case GIL_FORSHELL:
*lpIconIndex = 3;
break;
case GIL_OPENICON:
*lpIconIndex = 4;
break;
default:
hrReturn = S_FALSE;
}
break;
}
End:
ENDCOMTRACE();
if (bstrName)
::SysFreeString(bstrName);
if (szExtension)
delete szExtension;
return(hrReturn);
}
date: Fri, 8 Feb 2008 09:15:00 -0800
author: Wayne Berry am
|
|