ReactOS 0.4.16-dev-424-ge4748fe
CRegFolder.cpp File Reference
#include <precomp.h>
Include dependency graph for CRegFolder.cpp:

Go to the source code of this file.

Classes

struct  CRegFolderInfo
 
class  CRegFolderEnum
 
class  CRegFolder
 

Macros

#define DEFAULTSORTORDERINDEX   0x80
 

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)
 
static HRESULT CRegItemContextMenu_CreateInstance (PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, IContextMenu **ppcm)
 
static UINT GetRegItemCLSIDOffset (PIDLTYPE type)
 
static LPITEMIDLIST CreateRegItem (PIDLTYPE type, REFCLSID clsid, BYTE order=0)
 
static LPITEMIDLIST CreateRegItem (PIDLTYPE type, LPCWSTR clsidstr)
 
HRESULT FormatGUIDKey (LPWSTR KeyName, SIZE_T KeySize, LPCWSTR RegPath, const GUID *riid)
 
static DWORD SHELL_QueryCLSIDValue (_In_ REFCLSID clsid, _In_opt_ LPCWSTR SubKey, _In_opt_ LPCWSTR Value, _In_opt_ PVOID pData, _In_opt_ PDWORD pSize)
 
static bool HasCLSIDShellFolderValue (REFCLSID clsid, LPCWSTR Value)
 
HRESULT CGuidItemExtractIcon_CreateInstance (LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
 
static HRESULT CALLBACK RegFolderContextMenuCallback (IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HRESULT CRegFolder_CreateInstance (PREGFOLDERINITDATA pInit, LPCITEMIDLIST pidlRoot, REFIID riid, void **ppv)
 

Macro Definition Documentation

◆ DEFAULTSORTORDERINDEX

#define DEFAULTSORTORDERINDEX   0x80

Definition at line 28 of file CRegFolder.cpp.

Enumeration Type Documentation

◆ REGFOLDERCOLUMNINDEX

Enumerator
COL_NAME 
COL_TYPE 
COL_INFOTIP 
REGFOLDERCOLUMNCOUNT 

Definition at line 300 of file CRegFolder.cpp.

301{
306};
@ REGFOLDERCOLUMNCOUNT
Definition: CRegFolder.cpp:305
@ COL_INFOTIP
Definition: CRegFolder.cpp:304
@ COL_NAME
Definition: CRegFolder.cpp:302
@ COL_TYPE
Definition: CRegFolder.cpp:303
#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

◆ CGuidItemExtractIcon_CreateInstance()

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

Definition at line 128 of file CRegFolder.cpp.

129{
130 CComPtr<IDefaultExtractIconInit> initIcon;
131 HRESULT hr;
132 GUID const * riid;
133 int icon_idx;
134 WCHAR wTemp[MAX_PATH];
135
137 if (FAILED(hr))
138 return hr;
139
140 if (_ILIsDesktop(pidl))
141 {
142 initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
143 return initIcon->QueryInterface(iid, ppvOut);
144 }
145
146 riid = _ILGetGUIDPointer(pidl);
147 if (!riid)
148 return E_FAIL;
149
150 /* Choose a correct icon for Recycle Bin (full or empty) */
151 const WCHAR* iconname = NULL;
152 if (_ILIsBitBucket(pidl))
153 {
154 CComPtr<IEnumIDList> EnumIDList;
156
157 CComPtr<IShellFolder2> psfRecycleBin;
158 CComPtr<IShellFolder> psfDesktop;
159 hr = SHGetDesktopFolder(&psfDesktop);
160
161 if (SUCCEEDED(hr))
162 hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder2, &psfRecycleBin));
163 if (SUCCEEDED(hr))
164 hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList);
165
166 ULONG itemcount;
167 LPITEMIDLIST pidl = NULL;
168 if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK)
169 {
170 CoTaskMemFree(pidl);
171 iconname = L"Full";
172 } else {
173 iconname = L"Empty";
174 }
175 }
176
177 /* Prepare registry path for loading icons of My Computer and other shell extensions */
179
181 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s",
182 riid);
184 return hr;
185
186 /* Load icon for the current user */
187 BOOL ret = HCU_GetIconW(KeyName, wTemp, iconname, _countof(wTemp), &icon_idx);
188 if (!ret)
189 {
190 /* Failed, load default system-wide icon */
191 hr = FormatGUIDKey(KeyName, _countof(KeyName), L"CLSID\\%s", riid);
193 return hr;
194
195 ret = HCR_GetIconW(KeyName, wTemp, iconname, _countof(wTemp), &icon_idx);
196 }
197
198 if (ret)
199 {
200 /* Success, set loaded icon */
201 initIcon->SetNormalIcon(wTemp, icon_idx);
202 }
203 else
204 {
205 /* Everything has failed, set blank paper icon */
206 WARN("Failed to load an icon for the item, setting blank icon\n");
207 initIcon->SetNormalIcon(swShell32Name, IDI_SHELL_DOCUMENT - 1);
208 }
209
210 return initIcon->QueryInterface(iid, ppvOut);
211}
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:64
#define WARN(fmt,...)
Definition: precomp.h:61
#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
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
REFIID riid
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define L(x)
Definition: ntvdm.h:50
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:2091
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2392
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:314
HRESULT hr
Definition: shlfolder.c:183
#define IDI_SHELL_DESKTOP
Definition: shresdef.h:587
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:553
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)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CRegFolder::GetUIObjectOf().

◆ CreateRegItem() [1/2]

static LPITEMIDLIST CreateRegItem ( PIDLTYPE  type,
LPCWSTR  clsidstr 
)
static

Definition at line 58 of file CRegFolder.cpp.

59{
61 return SUCCEEDED(CLSIDFromString(clsidstr, &clsid)) ? CreateRegItem(type, clsid) : NULL;
62}
static LPITEMIDLIST CreateRegItem(PIDLTYPE type, REFCLSID clsid, BYTE order=0)
Definition: CRegFolder.cpp:38
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
REFCLSID clsid
Definition: msctf.c:82

◆ CreateRegItem() [2/2]

static LPITEMIDLIST CreateRegItem ( PIDLTYPE  type,
REFCLSID  clsid,
BYTE  order = 0 
)
static

Definition at line 38 of file CRegFolder.cpp.

39{
40#if 1 // FIXME: CControlPanelFolder is not ready for this yet
41 if (type == PT_CONTROLS_NEWREGITEM)
42 type = PT_CONTROLS_OLDREGITEM;
43#endif
45 const UINT cb = offset + sizeof(CLSID), cbTotal = cb + sizeof(WORD);
46 LPITEMIDLIST pidl = (LPITEMIDLIST)SHAlloc(cbTotal);
47 if (pidl)
48 {
49 ZeroMemory(pidl, cbTotal); // Note: This also initializes the terminator WORD
50 pidl->mkid.cb = cb;
51 pidl->mkid.abID[0] = type;
52 pidl->mkid.abID[1] = order;
53 *(CLSID*)(SIZE_T(pidl) + offset) = clsid;
54 }
55 return pidl;
56}
static UINT GetRegItemCLSIDOffset(PIDLTYPE type)
Definition: CRegFolder.cpp:33
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
GLintptr offset
Definition: glext.h:5920
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
IID CLSID
Definition: mstsclib_i.c:62
unsigned int UINT
Definition: ndis.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define ZeroMemory
Definition: winbase.h:1737

Referenced by CRegFolderEnum::AddItemsFromKey(), CRegFolderInfo::CreateItem(), CreateRegItem(), and CRegFolder::ParseDisplayName().

◆ CRegFolder_CreateInstance()

HRESULT CRegFolder_CreateInstance ( PREGFOLDERINITDATA  pInit,
LPCITEMIDLIST  pidlRoot,
REFIID  riid,
void **  ppv 
)

Definition at line 951 of file CRegFolder.cpp.

952{
953 return ShellObjectCreatorInit<CRegFolder>(pInit, pidlRoot, riid, ppv);
954}
PWDFDEVICE_INIT pInit
REFIID LPVOID * ppv
Definition: atlbase.h:39

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

◆ CRegItemContextMenu_CreateInstance()

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

Definition at line 921 of file CRegFolder.cpp.

923{
924 HKEY hKeys[3];
925 UINT cKeys = 0;
926
927 const GUID *pGuid = _ILGetGUIDPointer(apidl[0]);
928 if (pGuid)
929 {
930 WCHAR key[sizeof("CLSID\\") + 38];
931 wcscpy(key, L"CLSID\\");
932 StringFromGUID2(*pGuid, &key[6], 39);
933 AddClassKeyToArray(key, hKeys, &cKeys);
934 }
935
936 // FIXME: CRegFolder should be aggregated by its outer folder and should
937 // provide the attributes for all required non-registry folders.
938 // It currently does not so we have to ask the outer folder ourself so
939 // that we get the correct attributes for My Computer etc.
940 CComPtr<IShellFolder> pOuterSF;
941 SHBindToObject(NULL, pidlFolder, IID_PPV_ARG(IShellFolder, &pOuterSF));
942
943 SFGAOF att = (psf && cidl) ? SHGetAttributes(pOuterSF ? pOuterSF.p : psf, apidl[0], SFGAO_FOLDER) : 0;
944 if ((att & SFGAO_FOLDER) && (!pGuid || !HasCLSIDShellFolderValue(*pGuid, L"HideFolderVerbs")))
945 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
946
947 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, RegFolderContextMenuCallback, cKeys, hKeys, ppcm);
948}
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)
static HRESULT CALLBACK RegFolderContextMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CRegFolder.cpp:871
static bool HasCLSIDShellFolderValue(REFCLSID clsid, LPCWSTR Value)
Definition: CRegFolder.cpp:84
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:305
EXTERN_C HRESULT SHBindToObject(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:253
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
_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:311
Definition: copy.c:22
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by CRegFolder::GetUIObjectOf().

◆ FormatGUIDKey()

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

Definition at line 64 of file CRegFolder.cpp.

65{
66 WCHAR xriid[CHARS_IN_GUID];
67 StringFromGUID2(*riid, xriid, _countof(xriid));
68 return StringCchPrintfW(KeyName, KeySize, RegPath, xriid);
69}
#define CHARS_IN_GUID
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by CGuidItemExtractIcon_CreateInstance().

◆ GetRegItemCLSIDOffset()

static UINT GetRegItemCLSIDOffset ( PIDLTYPE  type)
inlinestatic

Definition at line 33 of file CRegFolder.cpp.

34{
35 return type == PT_CONTROLS_NEWREGITEM ? 14 : 4;
36}

Referenced by CreateRegItem(), CRegFolderInfo::GetCLSIDOffset(), and CRegFolderInfo::IsRegItem().

◆ HasCLSIDShellFolderValue()

static bool HasCLSIDShellFolderValue ( REFCLSID  clsid,
LPCWSTR  Value 
)
static

Definition at line 84 of file CRegFolder.cpp.

85{
86 return SHELL_QueryCLSIDValue(clsid, L"ShellFolder", Value, NULL, NULL) == ERROR_SUCCESS;
87}
static DWORD SHELL_QueryCLSIDValue(_In_ REFCLSID clsid, _In_opt_ LPCWSTR SubKey, _In_opt_ LPCWSTR Value, _In_opt_ PVOID pData, _In_opt_ PDWORD pSize)
Definition: CRegFolder.cpp:71
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by CRegItemContextMenu_CreateInstance().

◆ RegFolderContextMenuCallback()

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

Definition at line 871 of file CRegFolder.cpp.

873{
875 return SHELL32_DefaultContextMenuCallBack(psf, pdtobj, uMsg);
876
877 PIDLIST_ABSOLUTE pidlFolder;
878 PUITEMID_CHILD *apidl;
879 UINT cidl;
880 HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
882 return hr;
883
884 const CLSID* pCLSID;
885 CRegFolder *pRegFolder = static_cast<CRegFolder*>(psf);
886 const REQUIREDREGITEM* pRequired = pRegFolder->IsRequiredItem(apidl[0]);
887 if (pRequired && pRequired->pszCpl)
888 {
890 wsprintfW(buf, L"%hs", const_cast<LPCSTR>(pRequired->pszCpl));
892 }
893#if 0 // Should never happen, CDesktopFolder.cpp handles this
894 else if (_ILIsDesktop(pidlFolder) && _ILIsDesktop(apidl[0]))
895 {
897 }
898#endif
899 else if ((pCLSID = pRegFolder->IsRegItem(apidl[0])) != NULL)
900 {
901 if (CLSID_MyDocuments != *pCLSID)
902 {
904 }
905 else
906 {
907 FIXME("ROS MyDocs must implement IShellPropSheetExt\n");
908 hr = S_FALSE; // Just display the filesystem properties
909 }
910 }
911 else
912 {
913 hr = S_FALSE; // Tell the caller to run the default action
914 }
915
916 SHFree(pidlFolder);
917 _ILFreeaPidl(apidl, cidl);
918 return hr;
919}
#define FIXME(fmt,...)
Definition: precomp.h:53
const REQUIREDREGITEM * IsRequiredItem(LPCITEMIDLIST pidl) const
Definition: CRegFolder.cpp:325
WPARAM wParam
Definition: combotst.c:138
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
#define SHELL_ExecuteControlPanelCPL(hwnd, cpl)
Definition: precomp.h:185
HRESULT SHELL32_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdo, UINT msg)
Definition: shlfolder.cpp:525
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
HRESULT SHELL32_ShowShellExtensionProperties(const CLSID *pClsid, IDataObject *pDO)
Definition: item_prop.cpp:170
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2603
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:402
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2612
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
const CLSID * IsRegItem(LPCITEMIDLIST pidl) const
Definition: CRegFolder.cpp:98
LPCSTR pszCpl
Definition: shfldr.h:53
#define S_FALSE
Definition: winerror.h:2357
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by CRegItemContextMenu_CreateInstance().

◆ SHELL_QueryCLSIDValue()

static DWORD SHELL_QueryCLSIDValue ( _In_ REFCLSID  clsid,
_In_opt_ LPCWSTR  SubKey,
_In_opt_ LPCWSTR  Value,
_In_opt_ PVOID  pData,
_In_opt_ PDWORD  pSize 
)
static

Definition at line 71 of file CRegFolder.cpp.

72{
74 wcscpy(Path, L"CLSID\\");
75 StringFromGUID2(clsid, Path + 6, 39);
76 if (SubKey)
77 {
78 wcscpy(Path + 6 + 38, L"\\");
79 wcscpy(Path + 6 + 39, SubKey);
80 }
82}
PRTL_UNICODE_STRING_BUFFER Path
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define RRF_RT_ANY
Definition: winreg.h:64
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by HasCLSIDShellFolderValue().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )