Author: janderwald
Date: Sun May 10 00:03:08 2009
New Revision: 40874
URL:
http://svn.reactos.org/svn/reactos?rev=40874&view=rev
Log:
- Implement loading IShellIconOverlayIdentifier
- Implement retrieving overlay icon
Modified:
trunk/reactos/dll/win32/shell32/folders.c
trunk/reactos/dll/win32/shell32/shell32_main.c
trunk/reactos/dll/win32/shell32/shell32_main.h
Modified: trunk/reactos/dll/win32/shell32/folders.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders.c [iso-8859-1] Sun May 10 00:03:08 2009
@@ -23,6 +23,11 @@
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)
{
@@ -72,6 +77,111 @@
}
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;
}
/**************************************************************************
Modified: trunk/reactos/dll/win32/shell32/shell32_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shell32_…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shell32_main.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shell32_main.c [iso-8859-1] Sun May 10 00:03:08 2009
@@ -1324,6 +1324,7 @@
SIC_Initialize();
InitChangeNotifications();
+ InitIconOverlays();
break;
case DLL_PROCESS_DETACH:
Modified: trunk/reactos/dll/win32/shell32/shell32_main.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shell32_…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shell32_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shell32_main.h [iso-8859-1] Sun May 10 00:03:08 2009
@@ -148,6 +148,7 @@
/* Change Notification */
void InitChangeNotifications(void);
void FreeChangeNotifications(void);
+void InitIconOverlays(void);
/* file operation */
#define ASK_DELETE_FILE 1