ReactOS  0.4.15-dev-1397-g19779b3
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
 

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 CGuidItemExtractIcon_CreateInstance (LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
 
HRESULT CRegFolder_CreateInstance (const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName, REFIID riid, void **ppv)
 

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 92 of file CRegFolder.cpp.

98 {
99  HKEY hKeys[10];
100  UINT cKeys = 0;
101 
102  GUID *pGuid = _ILGetGUIDPointer(apidl[0]);
103  if (pGuid)
104  {
105  LPOLESTR pwszCLSID;
106  WCHAR key[60];
107 
108  wcscpy(key, L"CLSID\\");
109  HRESULT hr = StringFromCLSID(*pGuid, &pwszCLSID);
110  if (hr == S_OK)
111  {
112  wcscpy(&key[6], pwszCLSID);
113  AddClassKeyToArray(key, hKeys, &cKeys);
114  }
115  }
116  AddClassKeyToArray(L"Folder", hKeys, &cKeys);
117 
118  return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, RegFolderContextMenuCallback, cKeys, hKeys, ppcm);
119 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HRESULT CALLBACK RegFolderContextMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CRegFolder.cpp:25
HRESULT hr
Definition: shlfolder.c:183
void AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:267
static LPOLESTR
Definition: stg_prop.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define S_OK
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
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)
Definition: path.c:41
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412

Referenced by CRegFolder::GetUIObjectOf().

◆ CGuidItemExtractIcon_CreateInstance()

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

Definition at line 121 of file CRegFolder.cpp.

122 {
123  CComPtr<IDefaultExtractIconInit> initIcon;
124  HRESULT hr;
125  GUID const * riid;
126  int icon_idx;
127  WCHAR wTemp[MAX_PATH];
128 
130  if (FAILED(hr))
131  return hr;
132 
133  if (_ILIsDesktop(pidl))
134  {
135  initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
136  return initIcon->QueryInterface(iid, ppvOut);
137  }
138 
139  riid = _ILGetGUIDPointer(pidl);
140  if (!riid)
141  return E_FAIL;
142 
143  /* my computer and other shell extensions */
144  static const WCHAR fmt[] = { 'C', 'L', 'S', 'I', 'D', '\\',
145  '{', '%', '0', '8', 'l', 'x', '-', '%', '0', '4', 'x', '-', '%', '0', '4', 'x', '-',
146  '%', '0', '2', 'x', '%', '0', '2', 'x', '-', '%', '0', '2', 'x', '%', '0', '2', 'x',
147  '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '%', '0', '2', 'x', '}', 0
148  };
149  WCHAR xriid[50];
150 
151  swprintf(xriid, fmt,
152  riid->Data1, riid->Data2, riid->Data3,
153  riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
154  riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7]);
155 
156  const WCHAR* iconname = NULL;
157  if (_ILIsBitBucket(pidl))
158  {
159  static const WCHAR szFull[] = {'F','u','l','l',0};
160  static const WCHAR szEmpty[] = {'E','m','p','t','y',0};
161  CComPtr<IEnumIDList> EnumIDList;
163 
164  CComPtr<IShellFolder2> psfRecycleBin;
165  CComPtr<IShellFolder> psfDesktop;
166  hr = SHGetDesktopFolder(&psfDesktop);
167 
168  if (SUCCEEDED(hr))
169  hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder2, &psfRecycleBin));
170  if (SUCCEEDED(hr))
171  hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList);
172 
173  ULONG itemcount;
174  LPITEMIDLIST pidl = NULL;
175  if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK)
176  {
177  CoTaskMemFree(pidl);
178  iconname = szFull;
179  } else {
180  iconname = szEmpty;
181  }
182  }
183 
184  if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx))
185  {
186  initIcon->SetNormalIcon(wTemp, icon_idx);
187  }
188  else
189  {
190  if (IsEqualGUID(*riid, CLSID_MyComputer))
191  initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_COMPUTER);
192  else if (IsEqualGUID(*riid, CLSID_MyDocuments))
193  initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_DOCUMENTS);
194  else if (IsEqualGUID(*riid, CLSID_NetworkPlaces))
195  initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_MY_NETWORK_PLACES);
196  else
197  initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_FOLDER);
198  }
199 
200  return initIcon->QueryInterface(iid, ppvOut);
201 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:294
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
#define IDI_SHELL_DESKTOP
Definition: shresdef.h:531
if SUCCEEDED(hr)
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:1931
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
static const WCHAR szEmpty[]
Definition: provider.c:50
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2314
#define IDI_SHELL_MY_COMPUTER
Definition: shresdef.h:512
#define MAX_PATH
Definition: compat.h:34
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define IDI_SHELL_FOLDER
Definition: shresdef.h:500
#define IDI_SHELL_MY_NETWORK_PLACES
Definition: shresdef.h:514
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define S_OK
Definition: intsafe.h:51
#define IDI_SHELL_MY_DOCUMENTS
Definition: shresdef.h:622
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
unsigned int ULONG
Definition: retypes.h:1
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
Definition: dsound.c:943

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 785 of file CRegFolder.cpp.

786 {
787  return ShellObjectCreatorInit<CRegFolder>(pGuid, pidlRoot, lpszPath, lpszEnumKeyName, riid, ppv);
788 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39

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

◆ 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 S_OK;
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 (32 >= (UINT_PTR)ShellExecuteW(hwnd,
45  L"open",
46  L"rundll32.exe",
47  L"shell32.dll,Control_RunDLL sysdm.cpl",
48  NULL,
50  {
51  hr = E_FAIL;
52  }
53  }
54  else if (_ILIsDesktop(apidl[0]))
55  {
56  if (32 >= (UINT_PTR)ShellExecuteW(hwnd,
57  L"open",
58  L"rundll32.exe",
59  L"shell32.dll,Control_RunDLL desk.cpl",
60  NULL,
62  {
63  hr = E_FAIL;
64  }
65  }
66  else if (_ILIsNetHood(apidl[0]))
67  {
68  // FIXME path!
69  if (32 >= (UINT_PTR)ShellExecuteW(NULL,
70  L"open",
71  L"explorer.exe",
72  L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}",
73  NULL,
75  {
76  hr = E_FAIL;
77  }
78  }
79  else if (_ILIsBitBucket(apidl[0]))
80  {
81  /* FIXME: detect the drive path of bitbucket if appropiate */
83  hr = E_FAIL;
84  }
85 
86  SHFree(pidlFolder);
87  _ILFreeaPidl(apidl, cidl);
88 
89  return hr;
90 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SW_SHOWDEFAULT
Definition: winuser.h:774
HRESULT hr
Definition: shlfolder.c:183
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1920
BOOL _ILIsNetHood(LPCITEMIDLIST pidl)
Definition: pidl.c:1909
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
#define E_FAIL
Definition: ddrawi.h:102
WPARAM wParam
Definition: combotst.c:138
BOOL SH_ShowRecycleBinProperties(WCHAR sDrive)
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:1931
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:327
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2429
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
static const WCHAR L[]
Definition: oid.c:1250
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2635
#define S_OK
Definition: intsafe.h:51
#define SW_SHOWNORMAL
Definition: winuser.h:764
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274

Referenced by CGuidItemContextMenu_CreateInstance().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )