- Implement loading IShellIconOverlayIdentifier

- Implement retrieving overlay icon

svn path=/trunk/; revision=40874
This commit is contained in:
Johannes Anderwald 2009-05-09 20:03:08 +00:00
parent bf49aa19f7
commit 22220b79d8
3 changed files with 112 additions and 0 deletions

View file

@ -23,6 +23,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
WCHAR swShell32Name[MAX_PATH];
DWORD NumIconOverlayHandlers = 0;
IShellIconOverlayIdentifier ** Handlers = NULL;
const GUID IID_IShellIconOverlayIdentifier = {0x0c6c4200L, 0xc589, 0x11d0, {0x99, 0x9a, 0x00, 0xc0, 0x4f, 0xd6, 0x55, 0xe1}};
static HRESULT getIconLocationForFolder(LPCITEMIDLIST pidl, UINT uFlags,
LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
{
@ -74,6 +79,111 @@ static HRESULT getIconLocationForFolder(LPCITEMIDLIST pidl, UINT uFlags,
return S_OK;
}
void InitIconOverlays(void)
{
HKEY hKey;
DWORD dwIndex, dwResult, dwSize;
WCHAR szName[MAX_PATH];
WCHAR szValue[100];
CLSID clsid;
IShellIconOverlayIdentifier * Overlay;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers",0, KEY_READ, &hKey) != ERROR_SUCCESS)
return;
if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &dwResult, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return;
}
Handlers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwResult * sizeof(IShellIconOverlayIdentifier*));
if (!Handlers)
{
RegCloseKey(hKey);
return;
}
dwIndex = 0;
CoInitialize(0);
do
{
dwSize = sizeof(szName) / sizeof(WCHAR);
dwResult = RegEnumKeyExW(hKey, dwIndex, szName, &dwSize, NULL, NULL, NULL, NULL);
if (dwResult == ERROR_NO_MORE_ITEMS)
break;
if (dwResult == ERROR_SUCCESS)
{
dwSize = sizeof(szValue) / sizeof(WCHAR);
if (RegGetValueW(hKey, szName, NULL, RRF_RT_REG_SZ, NULL, szValue, &dwSize) == ERROR_SUCCESS)
{
CLSIDFromString(szValue, &clsid);
dwResult = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (LPVOID*)&Overlay);
if (dwResult == S_OK)
{
Handlers[NumIconOverlayHandlers] = Overlay;
NumIconOverlayHandlers++;
}
}
}
dwIndex++;
}while(1);
RegCloseKey(hKey);
}
BOOL
GetIconOverlay(LPCITEMIDLIST pidl, WCHAR * wTemp, int* pIndex)
{
DWORD Index;
HRESULT hResult;
int Priority;
int HighestPriority;
ULONG IconIndex;
ULONG Flags;
WCHAR szPath[MAX_PATH];
if(!SHGetPathFromIDListW(pidl, szPath))
return FALSE;
HighestPriority = 101;
IconIndex = NumIconOverlayHandlers;
for(Index = 0; Index < NumIconOverlayHandlers; Index++)
{
hResult = Handlers[Index]->lpVtbl->IsMemberOf(Handlers[Index], szPath, SFGAO_FILESYSTEM);
if (hResult == S_OK)
{
hResult = Handlers[Index]->lpVtbl->GetPriority(Handlers[Index], &Priority);
if (hResult == S_OK)
{
if (Priority < HighestPriority)
{
HighestPriority = Priority;
IconIndex = Index;
}
}
}
}
if (IconIndex == NumIconOverlayHandlers)
return FALSE;
hResult = Handlers[IconIndex]->lpVtbl->GetOverlayInfo(Handlers[IconIndex], wTemp, MAX_PATH, pIndex, &Flags);
if (hResult == S_OK)
return TRUE;
else
return FALSE;
}
/**************************************************************************
* IExtractIconW_Constructor
*/

View file

@ -1324,6 +1324,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
SIC_Initialize();
InitChangeNotifications();
InitIconOverlays();
break;
case DLL_PROCESS_DETACH:

View file

@ -148,6 +148,7 @@ HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags);
/* Change Notification */
void InitChangeNotifications(void);
void FreeChangeNotifications(void);
void InitIconOverlays(void);
/* file operation */
#define ASK_DELETE_FILE 1