ReactOS  0.4.14-dev-114-gc8cbd56
folders.cpp File Reference
#include "precomp.h"
Include dependency graph for folders.cpp:

Go to the source code of this file.

Functions

static void InitIconOverlays (void)
 
BOOL GetIconOverlay (LPCITEMIDLIST pidl, WCHAR *wTemp, int *pIndex)
 

Variables

WCHAR swShell32Name [MAX_PATH]
 
DWORD NumIconOverlayHandlers = 0
 
IShellIconOverlayIdentifier ** Handlers = NULL
 

Function Documentation

◆ GetIconOverlay()

BOOL GetIconOverlay ( LPCITEMIDLIST  pidl,
WCHAR wTemp,
int pIndex 
)

Definition at line 88 of file folders.cpp.

89 {
90  DWORD Index;
91  HRESULT hResult;
92  int Priority;
93  int HighestPriority;
95  ULONG Flags;
97 
98  if(!SHGetPathFromIDListW(pidl, szPath))
99  return FALSE;
100 
101  if (!Handlers)
103 
104  HighestPriority = 101;
106  for(Index = 0; Index < NumIconOverlayHandlers; Index++)
107  {
108  hResult = Handlers[Index]->IsMemberOf(szPath, SFGAO_FILESYSTEM);
109  if (hResult == S_OK)
110  {
111  hResult = Handlers[Index]->GetPriority(&Priority);
112  if (hResult == S_OK)
113  {
114  if (Priority < HighestPriority)
115  {
116  HighestPriority = Priority;
117  IconIndex = Index;
118  }
119  }
120  }
121  }
122 
124  return FALSE;
125 
126  hResult = Handlers[IconIndex]->GetOverlayInfo(wTemp, MAX_PATH, pIndex, &Flags);
127 
128  if (hResult == S_OK)
129  return TRUE;
130  else
131  return FALSE;
132 }
#define TRUE
Definition: types.h:120
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
DWORD NumIconOverlayHandlers
Definition: folders.cpp:24
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
IShellIconOverlayIdentifier ** Handlers
Definition: folders.cpp:25
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR IconIndex[]
Definition: install.c:51
#define S_OK
Definition: intsafe.h:59
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4564
static void InitIconOverlays(void)
Definition: folders.cpp:27
LPCWSTR szPath
Definition: env.c:35
unsigned int ULONG
Definition: retypes.h:1

◆ InitIconOverlays()

static void InitIconOverlays ( void  )
static

Definition at line 27 of file folders.cpp.

28 {
29  HKEY hKey;
30  DWORD dwIndex, dwResult, dwSize;
32  WCHAR szValue[100];
33  CLSID clsid;
34 
35  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
36  return;
37 
38  if (RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &dwResult, NULL, NULL, NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
39  {
40  RegCloseKey(hKey);
41  return;
42  }
43 
44  Handlers = (IShellIconOverlayIdentifier **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwResult * sizeof(IShellIconOverlayIdentifier*));
45  if (!Handlers)
46  {
47  RegCloseKey(hKey);
48  return;
49  }
50 
51  dwIndex = 0;
52 
53  CoInitialize(0);
54 
55  do
56  {
57  dwSize = sizeof(szName) / sizeof(WCHAR);
58  dwResult = RegEnumKeyExW(hKey, dwIndex, szName, &dwSize, NULL, NULL, NULL, NULL);
59 
60  if (dwResult == ERROR_NO_MORE_ITEMS)
61  break;
62 
63  if (dwResult == ERROR_SUCCESS)
64  {
65  dwSize = sizeof(szValue) / sizeof(WCHAR);
66  if (RegGetValueW(hKey, szName, NULL, RRF_RT_REG_SZ, NULL, szValue, &dwSize) == ERROR_SUCCESS)
67  {
69 
70  CLSIDFromString(szValue, &clsid);
71  dwResult = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellIconOverlayIdentifier, &Overlay));
72  if (dwResult == S_OK)
73  {
76  }
77  }
78  }
79 
80  dwIndex++;
81 
82  } while(1);
83 
84  RegCloseKey(hKey);
85 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define KEY_READ
Definition: nt_native.h:1023
#define RRF_RT_REG_SZ
Definition: driver.c:575
DWORD NumIconOverlayHandlers
Definition: folders.cpp:24
#define IID_PPV_ARG(Itype, ppType)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
IShellIconOverlayIdentifier ** Handlers
Definition: folders.cpp:25
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
REFCLSID clsid
Definition: msctf.c:84
static const WCHAR L[]
Definition: oid.c:1250
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
static const WCHAR szName[]
Definition: msipriv.h:1194
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2247
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
T * Detach()
Definition: atlcomcli.h:156
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by GetIconOverlay().

Variable Documentation

◆ Handlers

IShellIconOverlayIdentifier** Handlers = NULL

Definition at line 25 of file folders.cpp.

Referenced by GetIconOverlay(), and InitIconOverlays().

◆ NumIconOverlayHandlers

DWORD NumIconOverlayHandlers = 0

Definition at line 24 of file folders.cpp.

Referenced by GetIconOverlay(), and InitIconOverlays().

◆ swShell32Name