I have a file in windows desktop window. I want to custom-draw it instead of the normal icon and text. I almost implement it via the following steps, 1. make a dll in which the IExtractIcon interface is implemented, then register a icon handler shell extension for the file to make the dll loaded by explorer.exe. 2. in the dllmain function of the dll, subclass the desktop window to make custom-drawing.
This almost worked, but still have some problems: 1. In winxp, the dll loaded only once. after restart the PC, the dll wouldn't be loaded, except I maked another file with the same extension. I guess the reason is the desktop has cached the icon so it doesn't need to load the dll to extract icons. But why win7 works. What can i do to make the system always load the dll?
- The file always have an extension in file system, but when it is displayed in desktop, the extension might not be displayed. How can I get the full name of the file according to the desktop list-view item?
or is there any other way to make the explorer.exe load my dll automatically?
here is the IExtractIcon code:
HRESULT CShellIcon::GetIconLocation(UINT uFlags, LPWSTR szIconFile, UINT cchMax, LPINT piIndex, UINT* pwFlags)
{
// I inject the dll to subclass the desktop window
SubclassDesktop();
*piIndex = 0;
*pwFlags = GIL_DONTCACHE | GIL_NOTFILENAME | GIL_PERINSTANCE;
return S_FALSE;
}
HRESULT CShellIcon::Extract(LPCTSTR pszFile, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize )
{
phiconLarge = NULL;
phiconSmall = NULL;
return S_OK;
}