ReactOS 0.4.15-dev-7788-g1ad9096
folders.cpp
Go to the documentation of this file.
1/*
2 * Copyright 1997 Marcus Meissner
3 * Copyright 1998 Juergen Schmied
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include "precomp.h"
21
23
25IShellIconOverlayIdentifier ** Handlers = NULL;
26
27static void InitIconOverlays(void)
28{
29 HKEY hKey;
30 DWORD dwIndex, dwResult, dwSize;
32 WCHAR szValue[100];
34
35 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
36 return;
37
39 {
41 return;
42 }
43
44 Handlers = (IShellIconOverlayIdentifier **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwResult * sizeof(IShellIconOverlayIdentifier*));
45 if (!Handlers)
46 {
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);
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
85}
86
87BOOL
89{
91 HRESULT hResult;
92 int Priority;
93 int HighestPriority;
97
99 return FALSE;
100
101 if (!Handlers)
103
104 HighestPriority = 101;
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;
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 RegCloseKey(hKey)
Definition: registry.h:49
T * Detach()
Definition: atlcomcli.h:186
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1969
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:2533
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:3691
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define RRF_RT_REG_SZ
Definition: driver.c:575
static const WCHAR IconIndex[]
Definition: install.c:52
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static void InitIconOverlays(void)
Definition: folders.cpp:27
DWORD NumIconOverlayHandlers
Definition: folders.cpp:24
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
BOOL GetIconOverlay(LPCITEMIDLIST pidl, WCHAR *wTemp, int *pIndex)
Definition: folders.cpp:88
IShellIconOverlayIdentifier ** Handlers
Definition: folders.cpp:25
FxAutoRegKey hKey
#define S_OK
Definition: intsafe.h:52
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
REFCLSID clsid
Definition: msctf.c:82
_Out_ PULONG _Out_ PULONG pIndex
Definition: ndis.h:4565
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1344
static const WCHAR szName[]
Definition: powrprof.c:45
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:655
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define IID_PPV_ARG(Itype, ppType)
__wchar_t WCHAR
Definition: xmlstorage.h:180