ReactOS 0.4.16-dev-433-g6363f78
CFSFolder.cpp File Reference
#include <precomp.h>
Include dependency graph for CFSFolder.cpp:

Go to the source code of this file.

Classes

class  CFileSysEnum
 

Macros

#define SUPER_HIDDEN   (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)
 
#define GENERICSHELLVIEWCOLUMNS   _countof(GenericSFHeader)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static HRESULT SHELL32_GetCLSIDForDirectory (LPCWSTR pwszDir, LPCWSTR KeyName, CLSID *pclsidFolder)
 
static BOOL ItemIsFolder (PCUITEMID_CHILD pidl)
 
static LPCWSTR GetItemFileName (PCUITEMID_CHILD pidl, LPWSTR Buf, UINT cchMax)
 
static BOOL IsRealItem (const ITEMIDLIST &idl)
 
static void GetItemDescription (PCUITEMID_CHILD pidl, LPWSTR Buf, UINT cchMax)
 
static HKEY OpenKeyFromFileType (LPCWSTR pExtension, LPCWSTR KeyName)
 
static LPCWSTR ExtensionFromPidl (PCUIDLIST_RELATIVE pidl, LPWSTR Buf, UINT cchMax)
 
static HRESULT GetCLSIDForFileTypeFromExtension (LPCWSTR pExtension, LPCWSTR KeyName, CLSID *pclsid)
 
HRESULT GetCLSIDForFileType (PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID *pclsid)
 
static HRESULT getDefaultIconLocation (LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
 
static BOOL getShellClassInfo (LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
 
static HRESULT getIconLocationForFolder (IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
 
HRESULT CFSExtractIcon_CreateInstance (IShellFolder *psf, LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
 
HRESULT SHELL32_GetFSItemAttributes (IShellFolder *psf, LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
 
BOOL SHELL_FS_HideExtension (LPCWSTR szPath)
 
void SHELL_FS_ProcessDisplayFilename (LPWSTR szPath, DWORD dwFlags)
 
static HBITMAP DoLoadPicture (LPCWSTR pszFileName)
 

Variables

static const shvheader GenericSFHeader []
 

Macro Definition Documentation

◆ GENERICSHELLVIEWCOLUMNS

#define GENERICSHELLVIEWCOLUMNS   _countof(GenericSFHeader)

Definition at line 578 of file CFSFolder.cpp.

◆ SUPER_HIDDEN

Function Documentation

◆ CFSExtractIcon_CreateInstance()

HRESULT CFSExtractIcon_CreateInstance ( IShellFolder psf,
LPCITEMIDLIST  pidl,
REFIID  iid,
LPVOID ppvOut 
)

Definition at line 281 of file CFSFolder.cpp.

282{
283 CComPtr<IDefaultExtractIconInit> initIcon;
284 HRESULT hr;
285 int icon_idx = 0;
286 UINT flags = 0; // FIXME: Use it!
287 WCHAR wTemp[MAX_PATH] = L"";
288
290 if (FAILED(hr))
291 return hr;
292
293 if (_ILIsFolder (pidl))
294 {
296 pidl, 0, wTemp, _countof(wTemp),
297 &icon_idx,
298 &flags)))
299 {
300 initIcon->SetNormalIcon(wTemp, icon_idx);
301 // FIXME: if/when getIconLocationForFolder does something for
302 // GIL_FORSHORTCUT, code below should be uncommented. and
303 // the following line removed.
304 initIcon->SetShortcutIcon(wTemp, icon_idx);
305 }
307 pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp),
308 &icon_idx,
309 &flags)))
310 {
311 initIcon->SetDefaultIcon(wTemp, icon_idx);
312 }
313 // if (SUCCEEDED(getIconLocationForFolder(psf,
314 // pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp),
315 // &icon_idx,
316 // &flags)))
317 // {
318 // initIcon->SetShortcutIcon(wTemp, icon_idx);
319 // }
321 pidl, GIL_OPENICON, wTemp, _countof(wTemp),
322 &icon_idx,
323 &flags)))
324 {
325 initIcon->SetOpenIcon(wTemp, icon_idx);
326 }
327 }
328 else
329 {
330 WCHAR extbuf[256];
331 LPCWSTR pExtension = ExtensionFromPidl(pidl, extbuf, _countof(extbuf));
332 HKEY hkey = pExtension ? OpenKeyFromFileType(pExtension, L"DefaultIcon") : NULL;
333 if (!hkey)
334 WARN("Could not open DefaultIcon key!\n");
335
336 DWORD dwSize = sizeof(wTemp);
337 if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
338 {
339 WCHAR sNum[5];
340 if (ParseFieldW (wTemp, 2, sNum, 5))
341 icon_idx = _wtoi(sNum);
342 else
343 icon_idx = 0; /* sometimes the icon number is missing */
344 ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
345 PathUnquoteSpacesW(wTemp);
346
347 if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
348 {
349 ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
350 icon_idx = 0;
351
352 INT ret = PrivateExtractIconsW(wTemp, 0, 0, 0, NULL, NULL, 0, 0);
353 if (ret <= 0)
354 {
355 StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
356 if (lstrcmpiW(pExtension, L".exe") == 0 || lstrcmpiW(pExtension, L".scr") == 0)
357 icon_idx = -IDI_SHELL_EXE;
358 else
359 icon_idx = -IDI_SHELL_DOCUMENT;
360 }
361 }
362
363 initIcon->SetNormalIcon(wTemp, icon_idx);
364 }
365 else
366 {
367 initIcon->SetNormalIcon(swShell32Name, 0);
368 }
369
370 if (hkey)
371 RegCloseKey(hkey);
372 }
373
374 return initIcon->QueryInterface(iid, ppvOut);
375}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define WARN(fmt,...)
Definition: precomp.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
static LPCWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl, LPWSTR Buf, UINT cchMax)
Definition: CFSFolder.cpp:91
static HRESULT getIconLocationForFolder(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
Definition: CFSFolder.cpp:205
static HKEY OpenKeyFromFileType(LPCWSTR pExtension, LPCWSTR KeyName)
Definition: CFSFolder.cpp:61
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1461
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
GLbitfield flags
Definition: glext.h:7161
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2120
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:100
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLSPEC_HIDDEN
Definition: shellord.c:117
HRESULT hr
Definition: shlfolder.c:183
#define IDI_SHELL_EXE
Definition: shresdef.h:555
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:553
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
int32_t INT
Definition: typedefs.h:58
#define ILGDN_FORPARSING
Definition: undocshell.h:71
int ret
UINT WINAPI PrivateExtractIconsW(_In_reads_(MAX_PATH) LPCWSTR szFileName, _In_ int nIconIndex, _In_ int cxIcon, _In_ int cyIcon, _Out_writes_opt_(nIcons) HICON *phicon, _Out_writes_opt_(nIcons) UINT *piconid, _In_ UINT nIcons, _In_ UINT flags)
#define IID_PPV_ARG(Itype, ppType)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CFSFolder::GetUIObjectOf().

◆ DoLoadPicture()

static HBITMAP DoLoadPicture ( LPCWSTR  pszFileName)
static

Definition at line 1968 of file CFSFolder.cpp.

1969{
1970 // create stream from file
1971 HRESULT hr;
1972 CComPtr<IStream> pStream;
1974 FALSE, NULL, &pStream);
1975 if (FAILED(hr))
1976 return NULL;
1977
1978 // load the picture
1979 HBITMAP hbm = NULL;
1980 CComPtr<IPicture> pPicture;
1981 OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
1982
1983 // get the bitmap handle
1984 if (pPicture)
1985 {
1986 pPicture->get_Handle((OLE_HANDLE *)&hbm);
1987
1988 // copy the bitmap handle
1990 }
1991
1992 return hbm;
1993}
#define FALSE
Definition: types.h:117
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
HRESULT WINAPI OleLoadPicture(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
Definition: olepicture.c:2344
HRESULT WINAPI SHCreateStreamOnFileEx(LPCWSTR lpszPath, DWORD dwMode, DWORD dwAttributes, BOOL bCreate, IStream *lpTemplate, IStream **lppStream)
Definition: istream.c:401
static HBITMAP
Definition: button.c:44
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define STGM_READ
Definition: objbase.h:917
const GUID IID_IPicture
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define IMAGE_BITMAP
Definition: winuser.h:211
#define LR_CREATEDIBSECTION
Definition: winuser.h:1101
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2024

Referenced by CFSFolder::GetCustomViewInfo().

◆ ExtensionFromPidl()

static LPCWSTR ExtensionFromPidl ( PCUIDLIST_RELATIVE  pidl,
LPWSTR  Buf,
UINT  cchMax 
)
static

Definition at line 91 of file CFSFolder.cpp.

92{
93 if (!_ILIsValue(pidl))
94 {
95 ERR("Invalid pidl!\n");
96 return NULL;
97 }
98
99 LPCWSTR name = GetItemFileName(pidl, Buf, cchMax);
100 LPCWSTR pExtension = name ? PathFindExtensionW(name) : NULL;
101 if (!pExtension || *pExtension == UNICODE_NULL)
102 {
103 WARN("No extension for %S!\n", name);
104 return NULL;
105 }
106 return pExtension;
107}
UINT cchMax
#define ERR(fmt,...)
Definition: precomp.h:57
static LPCWSTR GetItemFileName(PCUITEMID_CHILD pidl, LPWSTR Buf, UINT cchMax)
Definition: CFSFolder.cpp:24
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define UNICODE_NULL
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2127
Definition: name.c:39

Referenced by CFSExtractIcon_CreateInstance(), and GetCLSIDForFileType().

◆ GetCLSIDForFileType()

HRESULT GetCLSIDForFileType ( PCUIDLIST_RELATIVE  pidl,
LPCWSTR  KeyName,
CLSID pclsid 
)

Definition at line 164 of file CFSFolder.cpp.

165{
166 WCHAR buf[256];
167 LPCWSTR pExtension = ExtensionFromPidl(pidl, buf, _countof(buf));
168 if (!pExtension)
169 return S_FALSE;
170
171 return GetCLSIDForFileTypeFromExtension(pExtension, KeyName, pclsid);
172}
static HRESULT GetCLSIDForFileTypeFromExtension(LPCWSTR pExtension, LPCWSTR KeyName, CLSID *pclsid)
Definition: CFSFolder.cpp:109
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
#define S_FALSE
Definition: winerror.h:2357

Referenced by CFSFolder::_CreateExtensionUIObject(), CFSFolder::_GetDropTarget(), CFSFolder::_GetIconHandler(), and CFSFolder::BindToObject().

◆ GetCLSIDForFileTypeFromExtension()

static HRESULT GetCLSIDForFileTypeFromExtension ( LPCWSTR  pExtension,
LPCWSTR  KeyName,
CLSID pclsid 
)
static

Definition at line 109 of file CFSFolder.cpp.

110{
111 HKEY hkeyProgId = OpenKeyFromFileType(pExtension, KeyName);
112 if (!hkeyProgId)
113 {
114 WARN("OpenKeyFromFileType failed for key %S\n", KeyName);
115 return S_FALSE;
116 }
117
118 WCHAR wszCLSIDValue[CHARS_IN_GUID];
119 DWORD dwSize = sizeof(wszCLSIDValue);
120 LONG res = RegGetValueW(hkeyProgId, NULL, NULL, RRF_RT_REG_SZ, NULL, wszCLSIDValue, &dwSize);
121 RegCloseKey(hkeyProgId);
122 if (res)
123 {
124 ERR("OpenKeyFromFileType succeeded but RegGetValueW failed\n");
125 return S_FALSE;
126 }
127
128#if 0
129 {
131 L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
132 wszCLSIDValue,
134 NULL,
135 NULL,
136 NULL);
137 if (res != ERROR_SUCCESS)
138 {
139 ERR("DropHandler extension %S not approved\n", wszName);
140 return E_ACCESSDENIED;
141 }
142 }
143#endif
144
146 L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Blocked",
147 wszCLSIDValue,
149 NULL,
150 NULL,
152 {
153 ERR("Extension %S not approved\n", wszCLSIDValue);
154 return E_ACCESSDENIED;
155 }
156
157 HRESULT hres = CLSIDFromString (wszCLSIDValue, pclsid);
159 return hres;
160
161 return S_OK;
162}
#define CHARS_IN_GUID
#define ERROR_SUCCESS
Definition: deptool.c:10
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define RRF_RT_REG_SZ
Definition: driver.c:575
GLuint res
Definition: glext.h:9613
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:465
long LONG
Definition: pedump.c:60
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CFileSysEnum::_AddFindResult(), GetCLSIDForFileType(), and SHELL32_GetFSItemAttributes().

◆ getDefaultIconLocation()

static HRESULT getDefaultIconLocation ( LPWSTR  szIconFile,
UINT  cchMax,
int piIndex,
UINT  uFlags 
)
static

Definition at line 175 of file CFSFolder.cpp.

176{
177 if (!HLM_GetIconW(IDI_SHELL_FOLDER - 1, szIconFile, cchMax, piIndex))
178 {
179 if (!HCR_GetIconW(L"Folder", szIconFile, NULL, cchMax, piIndex))
180 {
181 StringCchCopyW(szIconFile, cchMax, swShell32Name);
182 *piIndex = -IDI_SHELL_FOLDER;
183 }
184 }
185
186 if (uFlags & GIL_OPENICON)
187 {
188 // next icon
189 if (*piIndex < 0)
190 (*piIndex)--;
191 else
192 (*piIndex)++;
193 }
194
195 return S_OK;
196}
#define IDI_SHELL_FOLDER
Definition: treeview.c:21
UINT uFlags
Definition: api.c:59
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:314
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by getIconLocationForFolder().

◆ getIconLocationForFolder()

static HRESULT getIconLocationForFolder ( IShellFolder psf,
PCITEMID_CHILD  pidl,
UINT  uFlags,
LPWSTR  szIconFile,
UINT  cchMax,
int piIndex,
UINT pwFlags 
)
static

Definition at line 205 of file CFSFolder.cpp.

207{
208 DWORD dwFileAttrs;
209 WCHAR wszPath[MAX_PATH];
210 WCHAR wszIniFullPath[MAX_PATH];
211
212 if (uFlags & GIL_DEFAULTICON)
213 goto Quit;
214
215 // get path
216 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
217 goto Quit;
218 if (!PathIsDirectoryW(wszPath))
219 goto Quit;
220
221 // read-only or system folder?
222 dwFileAttrs = _ILGetFileAttributes(ILFindLastID(pidl), NULL, 0);
223 if ((dwFileAttrs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) == 0)
224 goto Quit;
225
226 // build the full path of ini file
227 StringCchCopyW(wszIniFullPath, _countof(wszIniFullPath), wszPath);
228 PathAppendW(wszIniFullPath, L"desktop.ini");
229
230 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
231 if (getShellClassInfo(L"IconFile", wszValue, _countof(wszValue), wszIniFullPath))
232 {
233 // wszValue --> wszTemp
234 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
235
236 // wszPath + wszTemp --> wszPath
237 if (PathIsRelativeW(wszTemp))
238 PathAppendW(wszPath, wszTemp);
239 else
240 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
241
242 // wszPath --> szIconFile
243 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
244
245 *piIndex = GetPrivateProfileIntW(L".ShellClassInfo", L"IconIndex", 0, wszIniFullPath);
246 return S_OK;
247 }
248 else if (getShellClassInfo(L"CLSID", wszValue, _countof(wszValue), wszIniFullPath) &&
249 HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
250 {
251 return S_OK;
252 }
253 else if (getShellClassInfo(L"CLSID2", wszValue, _countof(wszValue), wszIniFullPath) &&
254 HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
255 {
256 return S_OK;
257 }
258 else if (getShellClassInfo(L"IconResource", wszValue, _countof(wszValue), wszIniFullPath))
259 {
260 // wszValue --> wszTemp
261 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
262
263 // parse the icon location
264 *piIndex = PathParseIconLocationW(wszTemp);
265
266 // wszPath + wszTemp --> wszPath
267 if (PathIsRelativeW(wszTemp))
268 PathAppendW(wszPath, wszTemp);
269 else
270 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
271
272 // wszPath --> szIconFile
273 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
274 return S_OK;
275 }
276
277Quit:
278 return getDefaultIconLocation(szIconFile, cchMax, piIndex, uFlags);
279}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
UINT WINAPI GetPrivateProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val, LPCWSTR filename)
Definition: profile.c:1297
static BOOL getShellClassInfo(LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
Definition: CFSFolder.cpp:199
static HRESULT getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
Definition: CFSFolder.cpp:175
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define PathAppendW
Definition: pathcch.h:309
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2563
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198

Referenced by CFSExtractIcon_CreateInstance().

◆ GetItemDescription()

static void GetItemDescription ( PCUITEMID_CHILD  pidl,
LPWSTR  Buf,
UINT  cchMax 
)
static

Definition at line 44 of file CFSFolder.cpp.

45{
47 if (ItemIsFolder(pidl))
48 {
50 }
51 else
52 {
56 }
57 if (FAILED(hr) && cchMax)
58 Buf[0] = UNICODE_NULL;
59}
EXTERN_C HRESULT SHELL32_AssocGetFileDescription(PCWSTR Name, PWSTR Buf, UINT cchBuf)
EXTERN_C HRESULT SHELL32_AssocGetFSDirectoryDescription(PWSTR Buf, UINT cchBuf)
#define E_FAIL
Definition: ddrawi.h:102
static BOOL ItemIsFolder(PCUITEMID_CHILD pidl)
Definition: CFSFolder.cpp:17
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by CFSFolder::GetDetailsOf().

◆ GetItemFileName()

static LPCWSTR GetItemFileName ( PCUITEMID_CHILD  pidl,
LPWSTR  Buf,
UINT  cchMax 
)
static

Definition at line 24 of file CFSFolder.cpp.

25{
26 FileStructW* pDataW = _ILGetFileStructW(pidl);
27 if (pDataW)
28 return pDataW->wszName;
30 if (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG)
31 return (LPWSTR)pdata->u.file.szNames;
32 if (_ILSimpleGetTextW(pidl, Buf, cchMax))
33 return Buf;
34 return NULL;
35}
static PROTOCOLDATA * pdata
Definition: protocol.c:158
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2254
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2428
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2174
static BYTE _ILGetFSType(LPCITEMIDLIST pidl)
Definition: pidl.h:125
WCHAR wszName[1]
Definition: shlfolder.c:1555
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CFSFolder::_CreateShellExtInstance(), CFSFolder::BindToObject(), CFSFolder::CompareIDs(), ExtensionFromPidl(), GetItemDescription(), and CFSFolder::SetNameOf().

◆ getShellClassInfo()

static BOOL getShellClassInfo ( LPCWSTR  Entry,
LPWSTR  pszValue,
DWORD  cchValueLen,
LPCWSTR  IniFile 
)
static

Definition at line 199 of file CFSFolder.cpp.

200{
201 return GetPrivateProfileStringW(L".ShellClassInfo", Entry, NULL, pszValue, cchValueLen, IniFile);
202}
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
base of all file and directory entries
Definition: entries.h:83

Referenced by getIconLocationForFolder().

◆ IsRealItem()

static BOOL IsRealItem ( const ITEMIDLIST idl)
static

Definition at line 37 of file CFSFolder.cpp.

38{
39 // PIDLs created with SHSimpleIDListFromPath contain no data, otherwise, the item is "real"
40 FileStruct &fsitem = ((PIDLDATA*)idl.mkid.abID)->u.file;
41 return fsitem.dwFileSize | fsitem.uFileDate;
42}
BYTE abID[1]
Definition: shtypes.idl:28
SHITEMID mkid
Definition: shtypes.idl:34
WORD uFileDate
Definition: pidl.h:178
DWORD dwFileSize
Definition: pidl.h:177

Referenced by CFSFolder::CompareSortFoldersFirst().

◆ ItemIsFolder()

static BOOL ItemIsFolder ( PCUITEMID_CHILD  pidl)
static

Definition at line 17 of file CFSFolder.cpp.

18{
19 const BYTE mask = PT_FS | PT_FS_FOLDER_FLAG | PT_FS_FILE_FLAG;
20 const BYTE type = _ILGetType(pidl);
21 return (type & mask) == (PT_FS | PT_FS_FOLDER_FLAG) || (type == PT_FS && ILGetNext(pidl));
22}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLint GLuint mask
Definition: glext.h:6028
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:970
static BYTE _ILGetType(LPCITEMIDLIST pidl)
Definition: pidl.h:120
unsigned char BYTE
Definition: xxhash.c:193

Referenced by GetItemDescription().

◆ OpenKeyFromFileType()

static HKEY OpenKeyFromFileType ( LPCWSTR  pExtension,
LPCWSTR  KeyName 
)
static

Definition at line 61 of file CFSFolder.cpp.

62{
63 HKEY hkey;
64
66 DWORD dwSize = sizeof(FullName);
67 wsprintf(FullName, L"%s\\%s", pExtension, KeyName);
68
70 if (!res)
71 return hkey;
72
74 if (res)
75 {
76 WARN("Failed to get progid for extension %S (%x), error %d\n", pExtension, pExtension, res);
77 return NULL;
78 }
79
80 wcscat(FullName, L"\\");
82
83 hkey = NULL;
85 if (res)
86 WARN("Could not open key %S for extension %S\n", KeyName, pExtension);
87
88 return hkey;
89}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_READ
Definition: nt_native.h:1023
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define wsprintf
Definition: winuser.h:5877
_In_ PSTRING FullName
Definition: rtlfuncs.h:1665

Referenced by CFSExtractIcon_CreateInstance(), and GetCLSIDForFileTypeFromExtension().

◆ SHELL32_GetCLSIDForDirectory()

static HRESULT SHELL32_GetCLSIDForDirectory ( LPCWSTR  pwszDir,
LPCWSTR  KeyName,
CLSID pclsidFolder 
)
static

Definition at line 599 of file CFSFolder.cpp.

600{
601 WCHAR wszCLSIDValue[CHARS_IN_GUID];
602 WCHAR wszDesktopIni[MAX_PATH];
603
604 StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
605 StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
606
607 if (GetPrivateProfileStringW(L".ShellClassInfo",
608 KeyName,
609 L"",
610 wszCLSIDValue,
612 wszDesktopIni))
613 {
614 return CLSIDFromString(wszCLSIDValue, pclsidFolder);
615 }
616 return E_FAIL;
617}
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325

Referenced by CFileSysEnum::_AddFindResult(), CFSFolder::BindToObject(), and CFSFolder::CreateViewObject().

◆ SHELL32_GetFSItemAttributes()

HRESULT SHELL32_GetFSItemAttributes ( IShellFolder psf,
LPCITEMIDLIST  pidl,
LPDWORD  pdwAttributes 
)

Definition at line 619 of file CFSFolder.cpp.

620{
621 DWORD dwFileAttributes, dwShellAttributes;
622
623 if (!_ILIsFolderOrFile(pidl))
624 {
625 ERR("Got wrong type of pidl!\n");
626 *pdwAttributes &= SFGAO_CANLINK;
627 return S_OK;
628 }
629
631
632 /* Set common attributes */
633 dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
634 SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
635
636 BOOL bDirectory = (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
637
638 if (SFGAO_VALIDATE & *pdwAttributes)
639 {
640 STRRET strret;
641 LPWSTR path;
642 if (SUCCEEDED(psf->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret)) &&
643 SUCCEEDED(StrRetToStrW(&strret, pidl, &path)))
644 {
645 BOOL exists = PathFileExistsW(path);
646 SHFree(path);
647 if (!exists)
648 return E_FAIL;
649 }
650 }
651
652 if (!bDirectory)
653 {
654 // https://git.reactos.org/?p=reactos.git;a=blob;f=dll/shellext/zipfldr/res/zipfldr.rgs;hb=032b5aacd233cd7b83ab6282aad638c161fdc400#l9
655 WCHAR szFileName[MAX_PATH];
656 LPWSTR pExtension;
657 BOOL hasName = _ILSimpleGetTextW(pidl, szFileName, _countof(szFileName));
658 dwShellAttributes |= SFGAO_STREAM;
659
660 // Vista+ feature: Hidden files with a leading tilde treated as super-hidden
661 // See https://devblogs.microsoft.com/oldnewthing/20170526-00/?p=96235
662 if (hasName && szFileName[0] == '~' && (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
663 dwShellAttributes |= SFGAO_HIDDEN | SFGAO_SYSTEM;
664
665 if (hasName && (pExtension = PathFindExtensionW(szFileName)))
666 {
667 CLSID clsidFile;
668 // FIXME: Cache this?
669 HRESULT hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
670 if (hr == S_OK)
671 {
672 HKEY hkey;
673 hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
674 if (SUCCEEDED(hr))
675 {
677 DWORD dwSize = sizeof(dwAttributes);
679
681 if (Status == STATUS_SUCCESS)
682 {
683 TRACE("Augmenting '%S' with dwAttributes=0x%x\n", szFileName, dwAttributes);
684 dwShellAttributes |= dwAttributes;
685 }
686 ::RegCloseKey(hkey);
687
688 // This should be presented as directory!
689 bDirectory = (dwAttributes & SFGAO_FOLDER) != 0 || dwAttributes == 0;
690 TRACE("Treating '%S' as directory!\n", szFileName);
691 }
692 }
693 }
694 }
695
696 // This is a directory
697 if (bDirectory)
698 {
699 dwShellAttributes |= (SFGAO_FOLDER | /*SFGAO_HASSUBFOLDER |*/ SFGAO_STORAGE);
700
701 // Is this a real directory?
703 {
704 dwShellAttributes |= (SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
705 }
706 }
707
709 dwShellAttributes |= SFGAO_HIDDEN | SFGAO_GHOSTED;
710
712 dwShellAttributes |= SFGAO_READONLY;
713
715 dwShellAttributes |= SFGAO_SYSTEM;
716
718 dwShellAttributes |= SFGAO_COMPRESSED;
719
721 dwShellAttributes |= SFGAO_ENCRYPTED;
722
723 if ((SFGAO_NONENUMERATED & *pdwAttributes) && (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
724 {
726 if ((!(shcf & SHCONTF_INCLUDEHIDDEN)) || ((dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(shcf & SHCONTF_INCLUDESUPERHIDDEN)))
727 dwShellAttributes |= SFGAO_NONENUMERATED;
728 }
729
730 if (SFGAO_LINK & *pdwAttributes)
731 {
733
734 if (_ILGetExtension(pidl, ext, _countof(ext)) && !lstrcmpiW(ext, L"lnk"))
735 dwShellAttributes |= SFGAO_LINK;
736 }
737
738 if (SFGAO_HASSUBFOLDER & *pdwAttributes)
739 {
740 CComPtr<IShellFolder> psf2;
741 if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
742 {
743 CComPtr<IEnumIDList> pEnumIL;
744 if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
745 {
746 if (pEnumIL->Skip(1) == S_OK)
747 dwShellAttributes |= SFGAO_HASSUBFOLDER;
748 }
749 }
750 }
751
752 *pdwAttributes = dwShellAttributes;
753
754 TRACE ("-- 0x%08x\n", *pdwAttributes);
755 return S_OK;
756}
DWORD dwFileAttributes
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define SFGAO_SYSTEM
Definition: shobjidl.idl:198
static const WCHAR *const ext[]
Definition: module.c:53
#define RRF_RT_REG_DWORD
Definition: driver.c:578
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID, LPCWSTR, BOOL, BOOL, PHKEY)
Definition: reg.c:2422
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1631
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
static SHCONTF
Definition: ordinal.c:64
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define FILE_ATTRIBUTE_ENCRYPTED
Definition: ntifs_ex.h:385
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2516
#define STATUS_SUCCESS
Definition: shellext.h:65
SHCONTF SHELL_GetDefaultFolderEnumSHCONTF()
Definition: shlfolder.cpp:29
LSTATUS WINAPI SHRegGetValueW(_In_ HKEY hkey, _In_opt_ LPCWSTR pszSubKey, _In_opt_ LPCWSTR pszValue, _In_ SRRF srrfFlags, _Out_opt_ LPDWORD pdwType, _Out_writes_bytes_to_opt_(*pcbData, *pcbData) LPVOID pvData, _Inout_opt_ LPDWORD pcbData)
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwAttributes
Definition: vdmdbg.h:34

Referenced by CFSFolder::GetAttributesOf().

◆ SHELL_FS_HideExtension()

BOOL SHELL_FS_HideExtension ( LPCWSTR  szPath)

Definition at line 1438 of file CFSFolder.cpp.

1439{
1440 HKEY hKey;
1441 BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
1442 LONG lError;
1443
1444 doHide = !SHELL_GetSetting(SSF_SHOWEXTENSIONS, fShowExtensions);
1445
1446 if (!doHide)
1447 {
1449 if (*DotExt != 0)
1450 {
1452 LONG classlen = sizeof(classname);
1453 lError = RegQueryValueW(HKEY_CLASSES_ROOT, DotExt, classname, &classlen);
1454 if (lError == ERROR_SUCCESS)
1455 {
1457 if (lError == ERROR_SUCCESS)
1458 {
1459 lError = RegQueryValueExW(hKey, L"NeverShowExt", NULL, NULL, NULL, NULL);
1460 if (lError == ERROR_SUCCESS)
1461 doHide = TRUE;
1462
1464 }
1465 }
1466 }
1467 }
1468
1469 return doHide;
1470}
#define TRUE
Definition: types.h:120
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4241
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
FxAutoRegKey hKey
LPCWSTR szPath
Definition: env.c:37
WCHAR classname[128]
Definition: startup.c:15
#define SHELL_GetSetting(pss, ssf, field)
Definition: shellutils.h:826
#define SSF_SHOWEXTENSIONS
Definition: shlobj.h:1606

Referenced by CDefView::OnNotify(), CFSFolder::SetNameOf(), and SHELL_FS_ProcessDisplayFilename().

◆ SHELL_FS_ProcessDisplayFilename()

void SHELL_FS_ProcessDisplayFilename ( LPWSTR  szPath,
DWORD  dwFlags 
)

Definition at line 1472 of file CFSFolder.cpp.

1473{
1474 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
1475 if (!(dwFlags & SHGDN_FORPARSING) &&
1476 ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
1477 if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
1479 }
1480}
BOOL SHELL_FS_HideExtension(LPCWSTR szPath)
Definition: CFSFolder.cpp:1438
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by CFSFolder::GetDisplayNameOf(), and CRecycleBin::GetDisplayNameOf().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ GenericSFHeader

const shvheader GenericSFHeader[]
static
Initial value:
= {
}
#define IDS_SHV_COLUMN_TYPE
Definition: resource.h:75
#define IDS_SHV_COLUMN_NAME
Definition: resource.h:74
#define LVCFMT_LEFT
Definition: commctrl.h:2603
#define LVCFMT_RIGHT
Definition: commctrl.h:2604
#define IDS_SHV_COLUMN_SIZE
Definition: shresdef.h:50
#define IDS_SHV_COLUMN_MODIFIED
Definition: shresdef.h:52
#define IDS_SHV_COLUMN_COMMENTS
Definition: shresdef.h:67
#define IDS_SHV_COLUMN_ATTRIBUTES
Definition: shresdef.h:53
@ SHCOLSTATE_TYPE_INT
Definition: shtypes.idl:122
@ SHCOLSTATE_TYPE_DATE
Definition: shtypes.idl:123
@ SHCOLSTATE_TYPE_STR
Definition: shtypes.idl:121
@ SHCOLSTATE_SLOW
Definition: shtypes.idl:126
@ SHCOLSTATE_ONBYDEFAULT
Definition: shtypes.idl:125

Definition at line 569 of file CFSFolder.cpp.

Referenced by CFSFolder::GetDefaultFSColumnState(), and CFSFolder::GetFSColumnDetails().