ReactOS  0.4.15-dev-1207-g698a8e6
CAdminToolsFolder.cpp
Go to the documentation of this file.
1 /*
2  * Virtual Admin Tools Folder
3  *
4  * Copyright 2008 Johannes Anderwald
5  * Copyright 2009 Andrew Hill
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <precomp.h>
23 
25 
27 {
28  m_pidlInner = NULL;
29 }
30 
32 {
33  if(m_pidlInner)
35 }
36 
38  ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
39 {
40  return m_pisfInner->ParseDisplayName(hwndOwner, pbc, lpszDisplayName, pchEaten, ppidl, pdwAttributes);
41 }
42 
43 HRESULT WINAPI CAdminToolsFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
44 {
45  return m_pisfInner->EnumObjects(hwndOwner, dwFlags, ppEnumIDList);
46 }
47 
49 {
50  return m_pisfInner->BindToObject(pidl, pbcReserved, riid, ppvOut);
51 }
52 
54 {
55  return m_pisfInner->BindToStorage(pidl, pbcReserved, riid, ppvOut);
56 }
57 
59 {
60  return m_pisfInner->CompareIDs(lParam, pidl1, pidl2);
61 }
62 
64 {
65  return m_pisfInner->CreateViewObject(hwndOwner, riid, ppvOut);
66 }
67 
69 {
70  static const DWORD dwAdminToolsAttributes =
71  SFGAO_STORAGE | SFGAO_STORAGEANCESTOR | SFGAO_FILESYSANCESTOR |
72  SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
73 
74  if(cidl)
75  return m_pisfInner->GetAttributesOf(cidl, apidl, rgfInOut);
76 
77  if (!rgfInOut || !apidl)
78  return E_INVALIDARG;
79 
80  if (*rgfInOut == 0)
81  *rgfInOut = ~0;
82 
83  *rgfInOut &= dwAdminToolsAttributes;
84 
85  /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
86  *rgfInOut &= ~SFGAO_VALIDATE;
87 
88  return S_OK;
89 }
90 
92  REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
93 {
94  return m_pisfInner->GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut);
95 }
96 
98 {
99  if (!strRet || !pidl)
100  return E_INVALIDARG;
101 
102  /* If we got an fs item just forward to the fs folder */
103  if (!_ILIsSpecialFolder(pidl))
104  return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
105 
106  /* The caller wants our path. Let fs folder handle it */
109  {
110  /* Give an empty pidl to the fs folder to make it tell us its path */
111  if (pidl->mkid.cb)
112  pidl = ILGetNext(pidl);
113  return m_pisfInner->GetDisplayNameOf(pidl, dwFlags, strRet);
114  }
115 
116  ERR("Got empty pidl without SHGDN_FORPARSING\n");
117  return E_INVALIDARG;
118 }
119 
121  LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
122 {
123  return m_pisfInner->SetNameOf(hwndOwner, pidl, lpName, dwFlags, pPidlOut);
124 }
125 
127 {
128  return m_pisfInner->GetDefaultSearchGUID(pguid);
129 }
130 
132 {
133  return m_pisfInner->EnumSearches(ppenum);
134 }
135 
137 {
138  return m_pisfInner->GetDefaultColumn(dwRes, pSort, pDisplay);
139 }
140 
142 {
143  return m_pisfInner->GetDefaultColumnState(iColumn, pcsFlags);
144 }
145 
147 {
148  return m_pisfInner->GetDetailsEx(pidl, pscid, pv);
149 }
150 
152 {
153  return m_pisfInner->GetDetailsOf(pidl, iColumn, psd);
154 }
155 
157 {
158  return m_pisfInner->MapColumnToSCID(column, pscid);
159 }
160 
162 {
163  if (!lpClassId)
164  return E_POINTER;
165 
166  memcpy(lpClassId, &CLSID_AdminFolderShortcut, sizeof(CLSID));
167 
168  return S_OK;
169 }
170 
172 {
173  m_pidlInner = ILClone(pidl);
174  if (!m_pidlInner)
175  return E_OUTOFMEMORY;
176 
178  &CLSID_ShellFSFolder,
181 }
182 
184 {
185  if (!pidl)
186  return E_POINTER;
187  *pidl = ILClone(m_pidlInner);
188  return S_OK;
189 }
const GUID CLSID_AdminFolderShortcut
virtual HRESULT WINAPI GetClassID(CLSID *lpClassId)
#define REFIID
Definition: guiddef.h:118
virtual HRESULT WINAPI GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
interface IBindCtx * LPBC
Definition: objfwd.h:18
virtual HRESULT WINAPI SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
#define GET_SHGDN_RELATION(dwFlags)
Definition: precomp.h:53
CComPtr< IShellFolder2 > m_pisfInner
REFIID riid
Definition: precomp.h:44
_In_ LPCSTR lpName
Definition: winbase.h:2752
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
virtual HRESULT WINAPI Initialize(PCIDLIST_ABSOLUTE pidl)
virtual HRESULT WINAPI EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
virtual HRESULT WINAPI EnumSearches(IEnumExtraSearch **ppenum)
virtual HRESULT WINAPI BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
virtual HRESULT WINAPI GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv)
static LPOLESTR
Definition: stg_prop.c:27
#define IID_PPV_ARG(Itype, ppType)
virtual HRESULT WINAPI CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2)
virtual HRESULT WINAPI GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd)
virtual HRESULT WINAPI BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
static BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
#define GET_SHGDN_FOR(dwFlags)
Definition: precomp.h:52
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
virtual HRESULT WINAPI ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
virtual HRESULT WINAPI GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)
#define CSIDL_COMMON_ADMINTOOLS
Definition: shlobj.h:2058
virtual HRESULT WINAPI GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut)
LONG HRESULT
Definition: typedefs.h:79
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
WINE_DEFAULT_DEBUG_CHANNEL(shell)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
virtual HRESULT WINAPI MapColumnToSCID(UINT column, SHCOLUMNID *pscid)
virtual HRESULT WINAPI GetCurFolder(PIDLIST_ABSOLUTE *pidl)
virtual HRESULT WINAPI CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
virtual HRESULT WINAPI GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
virtual HRESULT WINAPI GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
unsigned int UINT
Definition: ndis.h:50
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
static HRESULT SHELL32_CoCreateInitSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidlChild, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: CFindFolder.cpp:13
unsigned int ULONG
Definition: retypes.h:1
#define E_POINTER
Definition: winerror.h:2365
virtual HRESULT WINAPI GetDefaultSearchGUID(GUID *pguid)
LPARAM lParam
Definition: combotst.c:139
LPITEMIDLIST m_pidlInner