ReactOS 0.4.15-dev-8100-g1887773
CRegFolder.cpp File Reference
#include <precomp.h>
Include dependency graph for CRegFolder.cpp:

Go to the source code of this file.

Classes

class  CRegFolderEnum
 
class  CRegFolder
 

Enumerations

enum  REGFOLDERCOLUMNINDEX { COL_NAME = SHFSF_COL_NAME , COL_TYPE = SHFSF_COL_TYPE , COL_INFOTIP = SHFSF_COL_COMMENT , REGFOLDERCOLUMNCOUNT = max(COL_INFOTIP, COL_TYPE) + 1 }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
HRESULT CALLBACK RegFolderContextMenuCallback (IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT CGuidItemContextMenu_CreateInstance (PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, IContextMenu **ppcm)
 
HRESULT FormatGUIDKey (LPWSTR KeyName, SIZE_T KeySize, LPCWSTR RegPath, const GUID *riid)
 
HRESULT CGuidItemExtractIcon_CreateInstance (LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
 
HRESULT CRegFolder_CreateInstance (const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName, REFIID riid, void **ppv)
 

Enumeration Type Documentation

◆ REGFOLDERCOLUMNINDEX

Enumerator
COL_NAME 
COL_TYPE 
COL_INFOTIP 
REGFOLDERCOLUMNCOUNT 

Definition at line 291 of file CRegFolder.cpp.

292{
297};
@ REGFOLDERCOLUMNCOUNT
Definition: CRegFolder.cpp:296
@ COL_INFOTIP
Definition: CRegFolder.cpp:295
@ COL_NAME
Definition: CRegFolder.cpp:293
@ COL_TYPE
Definition: CRegFolder.cpp:294
#define SHFSF_COL_COMMENT
Definition: shfldr.h:48
#define SHFSF_COL_NAME
Definition: shfldr.h:43
#define SHFSF_COL_TYPE
Definition: shfldr.h:45
#define max(a, b)
Definition: svc.c:63

Function Documentation

◆ CGuidItemContextMenu_CreateInstance()

HRESULT CGuidItemContextMenu_CreateInstance ( PCIDLIST_ABSOLUTE  pidlFolder,
HWND  hwnd,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
IShellFolder psf,
IContextMenu **  ppcm 
)

Definition at line 87 of file CRegFolder.cpp.

93{
94 HKEY hKeys[10];
95 UINT cKeys = 0;
96
97 GUID *pGuid = _ILGetGUIDPointer(apidl[0]);
98 if (pGuid)
99 {
100 LPOLESTR pwszCLSID;
101 WCHAR key[60];
102
103 wcscpy(key, L"CLSID\\");
104 HRESULT hr = StringFromCLSID(*pGuid, &pwszCLSID);
105 if (hr == S_OK)
106 {
107 wcscpy(&key[6], pwszCLSID);
108 AddClassKeyToArray(key, hKeys, &cKeys);
109 CoTaskMemFree(pwszCLSID);
110 }
111 }
112 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
113
114 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, RegFolderContextMenuCallback, cKeys, hKeys, ppcm);
115}
HRESULT WINAPI CDefFolderMenu_Create2(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeyClsKeys, IContextMenu **ppcm)
HRESULT CALLBACK RegFolderContextMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CRegFolder.cpp:25
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define S_OK
Definition: intsafe.h:52
static LPOLESTR
Definition: stg_prop.c:27
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2356
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LSTATUS AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:277
HRESULT hr
Definition: shlfolder.c:183
Definition: copy.c:22
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CRegFolder::GetUIObjectOf().

◆ CGuidItemExtractIcon_CreateInstance()

HRESULT CGuidItemExtractIcon_CreateInstance ( LPCITEMIDLIST  pidl,
REFIID  iid,
LPVOID ppvOut 
)

Definition at line 127 of file CRegFolder.cpp.

128{
129 CComPtr<IDefaultExtractIconInit> initIcon;
130 HRESULT hr;
131 GUID const * riid;
132 int icon_idx;
133 WCHAR wTemp[MAX_PATH];
134
136 if (FAILED(hr))
137 return hr;
138
139 if (_ILIsDesktop(pidl))
140 {
141 initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
142 return initIcon->QueryInterface(iid, ppvOut);
143 }
144
145 riid = _ILGetGUIDPointer(pidl);
146 if (!riid)
147 return E_FAIL;
148
149 /* Choose a correct icon for Recycle Bin (full or empty) */
150 const WCHAR* iconname = NULL;
151 if (_ILIsBitBucket(pidl))
152 {
153 CComPtr<IEnumIDList> EnumIDList;
155
156 CComPtr<IShellFolder2> psfRecycleBin;
157 CComPtr<IShellFolder> psfDesktop;
158 hr = SHGetDesktopFolder(&psfDesktop);
159
160 if (SUCCEEDED(hr))
161 hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder2, &psfRecycleBin));
162 if (SUCCEEDED(hr))
163 hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList);
164
165 ULONG itemcount;
166 LPITEMIDLIST pidl = NULL;
167 if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK)
168 {
169 CoTaskMemFree(pidl);
170 iconname = L"Full";
171 } else {
172 iconname = L"Empty";
173 }
174 }
175
176 /* Prepare registry path for loading icons of My Computer and other shell extensions */
178
180 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s",
181 riid);
183 return hr;
184
185 /* Load icon for the current user */
186 BOOL ret = HCU_GetIconW(KeyName, wTemp, iconname, _countof(wTemp), &icon_idx);
187 if (!ret)
188 {
189 /* Failed, load default system-wide icon */
190 hr = FormatGUIDKey(KeyName, _countof(KeyName), L"CLSID\\%s", riid);
192 return hr;
193
194 ret = HCR_GetIconW(KeyName, wTemp, iconname, _countof(wTemp), &icon_idx);
195 }
196
197 if (ret)
198 {
199 /* Success, set loaded icon */
200 initIcon->SetNormalIcon(wTemp, icon_idx);
201 }
202 else
203 {
204 /* Everything has failed, set blank paper icon */
205 WARN("Failed to load an icon for the item, setting blank icon\n");
206 initIcon->SetNormalIcon(swShell32Name, IDI_SHELL_DOCUMENT - 1);
207 }
208
209 return initIcon->QueryInterface(iid, ppvOut);
210}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
HRESULT FormatGUIDKey(LPWSTR KeyName, SIZE_T KeySize, LPCWSTR RegPath, const GUID *riid)
Definition: CRegFolder.cpp:117
#define WARN(fmt,...)
Definition: debug.h:115
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
REFIID riid
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:1973
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:291
#define IDI_SHELL_DESKTOP
Definition: shresdef.h:585
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:551
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define _countof(array)
Definition: sndvol32.h:70
uint32_t ULONG
Definition: typedefs.h:59
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
#define IID_PPV_ARG(Itype, ppType)

Referenced by CRegFolder::GetUIObjectOf().

◆ CRegFolder_CreateInstance()

HRESULT CRegFolder_CreateInstance ( const GUID pGuid,
LPCITEMIDLIST  pidlRoot,
LPCWSTR  lpszPath,
LPCWSTR  lpszEnumKeyName,
REFIID  riid,
void **  ppv 
)

Definition at line 866 of file CRegFolder.cpp.

867{
868 return ShellObjectCreatorInit<CRegFolder>(pGuid, pidlRoot, lpszPath, lpszEnumKeyName, riid, ppv);
869}
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by CDesktopFolder::FinalConstruct(), CDrivesFolder::FinalConstruct(), and CControlPanelFolder::Initialize().

◆ FormatGUIDKey()

HRESULT FormatGUIDKey ( LPWSTR  KeyName,
SIZE_T  KeySize,
LPCWSTR  RegPath,
const GUID riid 
)

Definition at line 117 of file CRegFolder.cpp.

118{
119 WCHAR xriid[40];
120
121 if (!StringFromGUID2(*riid, xriid, _countof(xriid) - 1))
122 return E_FAIL;
123
124 return StringCchPrintfW(KeyName, KeySize, RegPath, xriid);
125}
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by CGuidItemExtractIcon_CreateInstance().

◆ RegFolderContextMenuCallback()

HRESULT CALLBACK RegFolderContextMenuCallback ( IShellFolder psf,
HWND  hwnd,
IDataObject pdtobj,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 25 of file CRegFolder.cpp.

31{
33 return SHELL32_DefaultContextMenuCallBack(psf, pdtobj, uMsg);
34
35 PIDLIST_ABSOLUTE pidlFolder;
36 PUITEMID_CHILD *apidl;
37 UINT cidl;
38 HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
40 return hr;
41
42 if (_ILIsMyComputer(apidl[0]))
43 {
44 if (!SHELL_ExecuteControlPanelCPL(hwnd, L"sysdm.cpl"))
45 {
46 hr = E_FAIL;
47 }
48 }
49 else if (_ILIsDesktop(apidl[0]))
50 {
51 if (!SHELL_ExecuteControlPanelCPL(hwnd, L"desk.cpl"))
52 {
53 hr = E_FAIL;
54 }
55 }
56 else if (_ILIsNetHood(apidl[0]))
57 {
58 // FIXME path!
59 if (32 >= (UINT_PTR)ShellExecuteW(NULL,
60 L"open",
61 L"explorer.exe",
62 L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}",
63 NULL,
65 {
66 hr = E_FAIL;
67 }
68 }
69 else if (_ILIsBitBucket(apidl[0]))
70 {
71 /* FIXME: detect the drive path of bitbucket if appropiate */
73 hr = E_FAIL;
74 }
75 else
76 {
77 /* Tell the caller to run the default action */
78 hr = S_FALSE;
79 }
80
81 SHFree(pidlFolder);
82 _ILFreeaPidl(apidl, cidl);
83
84 return hr;
85}
WPARAM wParam
Definition: combotst.c:138
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
#define SHELL_ExecuteControlPanelCPL(hwnd, cpl)
Definition: precomp.h:147
HRESULT SHELL32_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdo, UINT msg)
Definition: shlfolder.cpp:515
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1962
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2677
BOOL _ILIsNetHood(LPCITEMIDLIST pidl)
Definition: pidl.c:1940
BOOL SH_ShowRecycleBinProperties(WCHAR sDrive)
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:361
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2486
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2598
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
#define S_FALSE
Definition: winerror.h:2357
#define SW_SHOWDEFAULT
Definition: winuser.h:780

Referenced by CGuidItemContextMenu_CreateInstance().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )