ReactOS 0.4.16-dev-2216-ga08d639
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, BOOL AllowFolder=FALSE)
 
static HRESULT GetCLSIDForFileTypeFromExtension (LPCWSTR pExtension, LPCWSTR KeyName, CLSID *pclsid)
 
HRESULT GetCLSIDForFileType (PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID *pclsid)
 
HRESULT GetItemCLSID (PCUIDLIST_RELATIVE pidl, 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 603 of file CFSFolder.cpp.

◆ SUPER_HIDDEN

Function Documentation

◆ CFSExtractIcon_CreateInstance()

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

Definition at line 296 of file CFSFolder.cpp.

297{
298 CComPtr<IDefaultExtractIconInit> initIcon;
299 HRESULT hr;
300 int icon_idx = 0;
301 UINT flags = 0; // FIXME: Use it!
302 WCHAR wTemp[MAX_PATH] = L"";
303
305 if (FAILED(hr))
306 return hr;
307
308 if (_ILIsFolder (pidl))
309 {
311 pidl, 0, wTemp, _countof(wTemp),
312 &icon_idx,
313 &flags)))
314 {
315 initIcon->SetNormalIcon(wTemp, icon_idx);
316 // FIXME: if/when getIconLocationForFolder does something for
317 // GIL_FORSHORTCUT, code below should be uncommented. and
318 // the following line removed.
319 initIcon->SetShortcutIcon(wTemp, icon_idx);
320 }
322 pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp),
323 &icon_idx,
324 &flags)))
325 {
326 initIcon->SetDefaultIcon(wTemp, icon_idx);
327 }
328 // if (SUCCEEDED(getIconLocationForFolder(psf,
329 // pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp),
330 // &icon_idx,
331 // &flags)))
332 // {
333 // initIcon->SetShortcutIcon(wTemp, icon_idx);
334 // }
336 pidl, GIL_OPENICON, wTemp, _countof(wTemp),
337 &icon_idx,
338 &flags)))
339 {
340 initIcon->SetOpenIcon(wTemp, icon_idx);
341 }
342 }
343 else
344 {
345 WCHAR extbuf[256];
346 LPCWSTR pExtension = ExtensionFromPidl(pidl, extbuf, _countof(extbuf));
347 HKEY hkey = pExtension ? OpenKeyFromFileType(pExtension, L"DefaultIcon") : NULL;
348 if (!hkey)
349 {
350 DWORD dwSize = sizeof(wTemp);
351 if (RegGetValueW(HKEY_CLASSES_ROOT, pExtension, L"PerceivedType", RRF_RT_REG_SZ, NULL,
352 wTemp, &dwSize) == ERROR_SUCCESS)
353 {
354 WCHAR szSubKey[MAX_PATH];
355 StringCchPrintfW(szSubKey, _countof(szSubKey),
356 L"SystemFileAssociations\\%s\\DefaultIcon", wTemp);
357 RegOpenKeyExW(HKEY_CLASSES_ROOT, szSubKey, 0, KEY_READ, &hkey);
358 }
359 }
360
361 DWORD dwSize = sizeof(wTemp);
362 if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
363 {
364 WCHAR sNum[5];
365 if (ParseFieldW (wTemp, 2, sNum, 5))
366 icon_idx = _wtoi(sNum);
367 else
368 icon_idx = 0; /* sometimes the icon number is missing */
369 ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
370 PathUnquoteSpacesW(wTemp);
371
372 if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
373 {
374 ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
375 icon_idx = 0;
376
377 INT ret = PrivateExtractIconsW(wTemp, 0, 0, 0, NULL, NULL, 0, 0);
378 if (ret <= 0)
379 {
380 StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
381 if (lstrcmpiW(pExtension, L".exe") == 0 || lstrcmpiW(pExtension, L".scr") == 0)
382 icon_idx = -IDI_SHELL_EXE;
383 else
384 icon_idx = -IDI_SHELL_DOCUMENT;
385 }
386 }
387
388 initIcon->SetNormalIcon(wTemp, icon_idx);
389 }
390 else
391 {
392 initIcon->SetNormalIcon(swShell32Name, 0);
393 }
394
395 if (hkey)
396 RegCloseKey(hkey);
397 }
398
399 return initIcon->QueryInterface(iid, ppvOut);
400}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define MAX_PATH
Definition: compat.h:34
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4265
void WINAPI PathUnquoteSpacesW(WCHAR *path)
Definition: path.c:2006
_ACRTIMP int __cdecl _wtoi(const wchar_t *)
Definition: wcs.c:2773
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
#define RRF_RT_REG_SZ
Definition: driver.c:575
static LPCWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl, LPWSTR Buf, UINT cchMax, BOOL AllowFolder=FALSE)
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:220
static HKEY OpenKeyFromFileType(LPCWSTR pExtension, LPCWSTR KeyName)
Definition: CFSFolder.cpp:61
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1461
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
GLbitfield flags
Definition: glext.h:7161
#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 KEY_READ
Definition: nt_native.h:1026
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2144
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:101
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:596
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:594
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
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:84
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
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)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CFSFolder::GetUIObjectOf().

◆ DoLoadPicture()

static HBITMAP DoLoadPicture ( LPCWSTR  pszFileName)
static

Definition at line 2024 of file CFSFolder.cpp.

2025{
2026 // create stream from file
2027 HRESULT hr;
2028 CComPtr<IStream> pStream;
2030 FALSE, NULL, &pStream);
2031 if (FAILED(hr))
2032 return NULL;
2033
2034 // load the picture
2035 HBITMAP hbm = NULL;
2036 CComPtr<IPicture> pPicture;
2037 OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
2038
2039 // get the bitmap handle
2040 if (pPicture)
2041 {
2042 pPicture->get_Handle((OLE_HANDLE *)&hbm);
2043
2044 // copy the bitmap handle
2046 }
2047
2048 return hbm;
2049}
#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:1109
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2290

Referenced by CFSFolder::GetCustomViewInfo().

◆ ExtensionFromPidl()

static LPCWSTR ExtensionFromPidl ( PCUIDLIST_RELATIVE  pidl,
LPWSTR  Buf,
UINT  cchMax,
BOOL  AllowFolder = FALSE 
)
static

Definition at line 91 of file CFSFolder.cpp.

92{
93 if (!AllowFolder && !_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 WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1274
static LPCWSTR GetItemFileName(PCUITEMID_CHILD pidl, LPWSTR Buf, UINT cchMax)
Definition: CFSFolder.cpp:24
#define UNICODE_NULL
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2151
Definition: name.c:39

Referenced by CFSExtractIcon_CreateInstance(), GetCLSIDForFileType(), and GetItemCLSID().

◆ 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:2705
#define S_FALSE
Definition: winerror.h:3451

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
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define FAILED_UNEXPECTEDLY
Definition: utils.cpp:30
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:4116
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

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

◆ getDefaultIconLocation()

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

Definition at line 190 of file CFSFolder.cpp.

191{
192 if (!HLM_GetIconW(IDI_SHELL_FOLDER - 1, szIconFile, cchMax, piIndex))
193 {
194 if (!HCR_GetIconW(L"Folder", szIconFile, NULL, cchMax, piIndex))
195 {
196 StringCchCopyW(szIconFile, cchMax, swShell32Name);
197 *piIndex = -IDI_SHELL_FOLDER;
198 }
199 }
200
201 if (uFlags & GIL_OPENICON)
202 {
203 // next icon
204 if (*piIndex < 0)
205 (*piIndex)--;
206 else
207 (*piIndex)++;
208 }
209
210 return S_OK;
211}
#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 220 of file CFSFolder.cpp.

222{
223 DWORD dwFileAttrs;
224 WCHAR wszPath[MAX_PATH];
225 WCHAR wszIniFullPath[MAX_PATH];
226
227 if (uFlags & GIL_DEFAULTICON)
228 goto Quit;
229
230 // get path
231 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
232 goto Quit;
233 if (!PathIsDirectoryW(wszPath))
234 goto Quit;
235
236 // read-only or system folder?
237 dwFileAttrs = _ILGetFileAttributes(ILFindLastID(pidl), NULL, 0);
238 if ((dwFileAttrs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) == 0)
239 goto Quit;
240
241 // build the full path of ini file
242 StringCchCopyW(wszIniFullPath, _countof(wszIniFullPath), wszPath);
243 PathAppendW(wszIniFullPath, L"desktop.ini");
244
245 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
246 if (getShellClassInfo(L"IconFile", wszValue, _countof(wszValue), wszIniFullPath))
247 {
248 // wszValue --> wszTemp
249 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
250
251 // wszPath + wszTemp --> wszPath
252 if (PathIsRelativeW(wszTemp))
253 PathAppendW(wszPath, wszTemp);
254 else
255 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
256
257 // wszPath --> szIconFile
258 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
259
260 *piIndex = GetPrivateProfileIntW(L".ShellClassInfo", L"IconIndex", 0, wszIniFullPath);
261 return S_OK;
262 }
263 else if (getShellClassInfo(L"CLSID", wszValue, _countof(wszValue), wszIniFullPath) &&
264 HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
265 {
266 return S_OK;
267 }
268 else if (getShellClassInfo(L"CLSID2", wszValue, _countof(wszValue), wszIniFullPath) &&
269 HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
270 {
271 return S_OK;
272 }
273 else if (getShellClassInfo(L"IconResource", wszValue, _countof(wszValue), wszIniFullPath))
274 {
275 // wszValue --> wszTemp
276 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
277
278 // parse the icon location
279 *piIndex = PathParseIconLocationW(wszTemp);
280
281 // wszPath + wszTemp --> wszPath
282 if (PathIsRelativeW(wszTemp))
283 PathAppendW(wszPath, wszTemp);
284 else
285 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
286
287 // wszPath --> szIconFile
288 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
289 return S_OK;
290 }
291
292Quit:
293 return getDefaultIconLocation(szIconFile, cchMax, piIndex, uFlags);
294}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:520
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
BOOL WINAPI PathIsRelativeW(const WCHAR *path)
Definition: path.c:1030
int WINAPI PathParseIconLocationW(WCHAR *path)
Definition: path.c:2644
static BOOL getShellClassInfo(LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
Definition: CFSFolder.cpp:214
static HRESULT getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
Definition: CFSFolder.cpp:190
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1729
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define PathAppendW
Definition: pathcch.h:310
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2585
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199

Referenced by CFSExtractIcon_CreateInstance().

◆ GetItemCLSID()

HRESULT GetItemCLSID ( PCUIDLIST_RELATIVE  pidl,
CLSID pclsid 
)

Definition at line 174 of file CFSFolder.cpp.

175{
176 WCHAR buf[256];
177 LPCWSTR pExt = ExtensionFromPidl(pidl, buf, _countof(buf), TRUE);
178 if (!pExt)
179 return E_FAIL;
180 HRESULT hr = E_FAIL;
181 if (!ItemIsFolder(pidl))
182 hr = GetCLSIDForFileTypeFromExtension(pExt, L"CLSID", pclsid);
183 // TODO: Should we handle folders with desktop.ini here?
184 if (hr != S_OK && pExt[0] == '.' && pExt[1] == '{')
185 hr = CLSIDFromString(pExt + 1, pclsid);
186 return hr;
187}
#define E_FAIL
Definition: ddrawi.h:102
#define TRUE
Definition: types.h:120
static BOOL ItemIsFolder(PCUITEMID_CHILD pidl)
Definition: CFSFolder.cpp:17

Referenced by CFSFolder::GetDetailsEx().

◆ 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)
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;
31 return (LPWSTR)pdata->u.file.szNames;
32 if (_ILSimpleGetTextW(pidl, Buf, cchMax))
33 return Buf;
34 return NULL;
35}
#define PT_FS_UNICODE_FLAG
Definition: lnktool.cpp:41
static PROTOCOLDATA * pdata
Definition: protocol.c:158
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2278
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2450
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2198
static BYTE _ILGetFSType(LPCITEMIDLIST pidl)
Definition: pidl.h:149
WCHAR wszName[1]
Definition: shlfolder.c:1557
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 214 of file CFSFolder.cpp.

215{
216 return GetPrivateProfileStringW(L".ShellClassInfo", Entry, NULL, pszValue, cchValueLen, IniFile);
217}
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783
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:202
DWORD dwFileSize
Definition: pidl.h:201

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
#define PT_FS
Definition: lnktool.cpp:40
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:977
static BYTE _ILGetType(LPCITEMIDLIST pidl)
Definition: pidl.h:144
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CFSFolder::GetDetailsEx(), GetItemCLSID(), GetItemDescription(), and CFSFolder::SetNameOf().

◆ 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}
wcscat
#define wsprintf
Definition: winuser.h:5976
_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 624 of file CFSFolder.cpp.

625{
626 WCHAR wszCLSIDValue[CHARS_IN_GUID];
627 WCHAR wszDesktopIni[MAX_PATH];
628
629 StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
630 StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
631
632 if (GetPrivateProfileStringW(L".ShellClassInfo",
633 KeyName,
634 L"",
635 wszCLSIDValue,
637 wszDesktopIni))
638 {
639 return CLSIDFromString(wszCLSIDValue, pclsidFolder);
640 }
641 return E_FAIL;
642}
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 644 of file CFSFolder.cpp.

645{
646 DWORD dwFileAttributes, dwShellAttributes;
647
648 if (!_ILIsFolderOrFile(pidl))
649 {
650 ERR("Got wrong type of pidl!\n");
651 *pdwAttributes &= SFGAO_CANLINK;
652 return S_OK;
653 }
654
656
657 /* Set common attributes */
658 dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
659 SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
660
661 BOOL bDirectory = (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
662
663 if (SFGAO_VALIDATE & *pdwAttributes)
664 {
665 STRRET strret;
666 LPWSTR path;
667 if (SUCCEEDED(psf->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret)) &&
668 SUCCEEDED(StrRetToStrW(&strret, pidl, &path)))
669 {
670 BOOL exists = PathFileExistsW(path);
671 SHFree(path);
672 if (!exists)
673 return E_FAIL;
674 }
675 }
676
677 if (!bDirectory)
678 {
679 // https://git.reactos.org/?p=reactos.git;a=blob;f=dll/shellext/zipfldr/res/zipfldr.rgs;hb=032b5aacd233cd7b83ab6282aad638c161fdc400#l9
680 WCHAR szFileName[MAX_PATH];
681 LPWSTR pExtension;
682 BOOL hasName = _ILSimpleGetTextW(pidl, szFileName, _countof(szFileName));
683 dwShellAttributes |= SFGAO_STREAM;
684
685 // Vista+ feature: Hidden files with a leading tilde treated as super-hidden
686 // See https://devblogs.microsoft.com/oldnewthing/20170526-00/?p=96235
687 if (hasName && szFileName[0] == '~' && (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
688 dwShellAttributes |= SFGAO_HIDDEN | SFGAO_SYSTEM;
689
690 if (hasName && (pExtension = PathFindExtensionW(szFileName)))
691 {
692 CLSID clsidFile;
693 // FIXME: Cache this?
694 HRESULT hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
695 if (hr == S_OK)
696 {
697 HKEY hkey;
698 hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
699 if (SUCCEEDED(hr))
700 {
702 DWORD dwSize = sizeof(dwAttributes);
704
706 if (Status == STATUS_SUCCESS)
707 {
708 TRACE("Augmenting '%S' with dwAttributes=0x%x\n", szFileName, dwAttributes);
709 dwShellAttributes |= dwAttributes;
710 }
711 ::RegCloseKey(hkey);
712
713 // This should be presented as directory!
714 bDirectory = (dwAttributes & SFGAO_FOLDER) != 0 || dwAttributes == 0;
715 TRACE("Treating '%S' as directory!\n", szFileName);
716 }
717 }
718 }
719 }
720
721 // This is a directory
722 if (bDirectory)
723 {
724 dwShellAttributes |= (SFGAO_FOLDER | /*SFGAO_HASSUBFOLDER |*/ SFGAO_STORAGE);
725
726 // Is this a real directory?
728 {
729 dwShellAttributes |= (SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
730 }
731 }
732
734 dwShellAttributes |= SFGAO_HIDDEN | SFGAO_GHOSTED;
735
737 dwShellAttributes |= SFGAO_READONLY;
738
740 dwShellAttributes |= SFGAO_SYSTEM;
741
743 dwShellAttributes |= SFGAO_COMPRESSED;
744
746 dwShellAttributes |= SFGAO_ENCRYPTED;
747
748 if ((SFGAO_NONENUMERATED & *pdwAttributes) && (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
749 {
751 if ((!(shcf & SHCONTF_INCLUDEHIDDEN)) || ((dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(shcf & SHCONTF_INCLUDESUPERHIDDEN)))
752 dwShellAttributes |= SFGAO_NONENUMERATED;
753 }
754
755 if (SFGAO_LINK & *pdwAttributes)
756 {
758
759 if (_ILGetExtension(pidl, ext, _countof(ext)) && !lstrcmpiW(ext, L"lnk"))
760 dwShellAttributes |= SFGAO_LINK;
761 }
762
763 if (SFGAO_HASSUBFOLDER & *pdwAttributes)
764 {
765 CComPtr<IShellFolder> psf2;
766 if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
767 {
768 CComPtr<IEnumIDList> pEnumIL;
769 if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
770 {
771 if (pEnumIL->Skip(1) == S_OK)
772 dwShellAttributes |= SFGAO_HASSUBFOLDER;
773 }
774 }
775 }
776
777 *pdwAttributes = dwShellAttributes;
778
779 TRACE ("-- 0x%08x\n", *pdwAttributes);
780 return S_OK;
781}
DWORD dwFileAttributes
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define SFGAO_SYSTEM
Definition: shobjidl.idl:198
static const WCHAR *const ext[]
Definition: module.c:53
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2607
#define RRF_RT_REG_DWORD
Definition: driver.c:578
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370
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:1761
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:61
#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:2538
#define STATUS_SUCCESS
Definition: shellext.h:65
SHCONTF SHELL_GetDefaultFolderEnumSHCONTF()
Definition: shlfolder.cpp:29
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwAttributes
Definition: vdmdbg.h:34
WINSHLWAPI LSTATUS WINAPI SHRegGetValueW(HKEY, LPCWSTR, LPCWSTR, SRRF, LPDWORD, LPVOID, LPDWORD)

Referenced by CFSFolder::GetAttributesOf().

◆ SHELL_FS_HideExtension()

BOOL SHELL_FS_HideExtension ( LPCWSTR  szPath)

Definition at line 1444 of file CFSFolder.cpp.

1445{
1446 HKEY hKey;
1447 BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
1448 LONG lError;
1449
1450 doHide = !SHELL_GetSetting(SSF_SHOWEXTENSIONS, fShowExtensions);
1451
1452 if (!doHide)
1453 {
1455 if (*DotExt != 0)
1456 {
1458 LONG classlen = sizeof(classname);
1459 lError = RegQueryValueW(HKEY_CLASSES_ROOT, DotExt, classname, &classlen);
1460 if (lError == ERROR_SUCCESS)
1461 {
1463 if (lError == ERROR_SUCCESS)
1464 {
1465 lError = RegQueryValueExW(hKey, L"NeverShowExt", NULL, NULL, NULL, NULL);
1466 if (lError == ERROR_SUCCESS)
1467 doHide = TRUE;
1468
1470 }
1471 }
1472 }
1473 }
1474 // TODO: else if "AlwaysShowExt"
1475
1476 return doHide;
1477}
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:902
#define SSF_SHOWEXTENSIONS
Definition: shlobj.h:1611

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

◆ SHELL_FS_ProcessDisplayFilename()

void SHELL_FS_ProcessDisplayFilename ( LPWSTR  szPath,
DWORD  dwFlags 
)

Definition at line 1479 of file CFSFolder.cpp.

1480{
1481 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
1482 if (!(dwFlags & SHGDN_FORPARSING) &&
1483 ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
1484 if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
1486 }
1487}
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1946
BOOL SHELL_FS_HideExtension(LPCWSTR szPath)
Definition: CFSFolder.cpp:1444
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141

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:89
#define IDS_SHV_COLUMN_NAME
Definition: resource.h:88
#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 594 of file CFSFolder.cpp.

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