ReactOS 0.4.16-dev-1056-gbe87e00
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 593 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 WARN("Could not open DefaultIcon key!\n");
350
351 DWORD dwSize = sizeof(wTemp);
352 if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
353 {
354 WCHAR sNum[5];
355 if (ParseFieldW (wTemp, 2, sNum, 5))
356 icon_idx = _wtoi(sNum);
357 else
358 icon_idx = 0; /* sometimes the icon number is missing */
359 ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
360 PathUnquoteSpacesW(wTemp);
361
362 if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
363 {
364 ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
365 icon_idx = 0;
366
367 INT ret = PrivateExtractIconsW(wTemp, 0, 0, 0, NULL, NULL, 0, 0);
368 if (ret <= 0)
369 {
370 StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
371 if (lstrcmpiW(pExtension, L".exe") == 0 || lstrcmpiW(pExtension, L".scr") == 0)
372 icon_idx = -IDI_SHELL_EXE;
373 else
374 icon_idx = -IDI_SHELL_DOCUMENT;
375 }
376 }
377
378 initIcon->SetNormalIcon(wTemp, icon_idx);
379 }
380 else
381 {
382 initIcon->SetNormalIcon(swShell32Name, 0);
383 }
384
385 if (hkey)
386 RegCloseKey(hkey);
387 }
388
389 return initIcon->QueryInterface(iid, ppvOut);
390}
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, 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
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1040
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:2137
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:581
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:579
#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 2032 of file CFSFolder.cpp.

2033{
2034 // create stream from file
2035 HRESULT hr;
2036 CComPtr<IStream> pStream;
2038 FALSE, NULL, &pStream);
2039 if (FAILED(hr))
2040 return NULL;
2041
2042 // load the picture
2043 HBITMAP hbm = NULL;
2044 CComPtr<IPicture> pPicture;
2045 OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
2046
2047 // get the bitmap handle
2048 if (pPicture)
2049 {
2050 pPicture->get_Handle((OLE_HANDLE *)&hbm);
2051
2052 // copy the bitmap handle
2054 }
2055
2056 return hbm;
2057}
#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:2275

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 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:2144
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: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: debug.h:83
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(), 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: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: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
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1098
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1585
#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:2578
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198

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:2271
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2443
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2191
static BYTE _ILGetFSType(LPCITEMIDLIST pidl)
Definition: pidl.h:129
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 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
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:182
DWORD dwFileSize
Definition: pidl.h:181

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:970
static BYTE _ILGetType(LPCITEMIDLIST pidl)
Definition: pidl.h:124
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
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
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define wsprintf
Definition: winuser.h:5885
_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 614 of file CFSFolder.cpp.

615{
616 WCHAR wszCLSIDValue[CHARS_IN_GUID];
617 WCHAR wszDesktopIni[MAX_PATH];
618
619 StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
620 StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
621
622 if (GetPrivateProfileStringW(L".ShellClassInfo",
623 KeyName,
624 L"",
625 wszCLSIDValue,
627 wszDesktopIni))
628 {
629 return CLSIDFromString(wszCLSIDValue, pclsidFolder);
630 }
631 return E_FAIL;
632}
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 634 of file CFSFolder.cpp.

635{
636 DWORD dwFileAttributes, dwShellAttributes;
637
638 if (!_ILIsFolderOrFile(pidl))
639 {
640 ERR("Got wrong type of pidl!\n");
641 *pdwAttributes &= SFGAO_CANLINK;
642 return S_OK;
643 }
644
646
647 /* Set common attributes */
648 dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
649 SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
650
651 BOOL bDirectory = (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
652
653 if (SFGAO_VALIDATE & *pdwAttributes)
654 {
655 STRRET strret;
656 LPWSTR path;
657 if (SUCCEEDED(psf->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strret)) &&
658 SUCCEEDED(StrRetToStrW(&strret, pidl, &path)))
659 {
660 BOOL exists = PathFileExistsW(path);
661 SHFree(path);
662 if (!exists)
663 return E_FAIL;
664 }
665 }
666
667 if (!bDirectory)
668 {
669 // https://git.reactos.org/?p=reactos.git;a=blob;f=dll/shellext/zipfldr/res/zipfldr.rgs;hb=032b5aacd233cd7b83ab6282aad638c161fdc400#l9
670 WCHAR szFileName[MAX_PATH];
671 LPWSTR pExtension;
672 BOOL hasName = _ILSimpleGetTextW(pidl, szFileName, _countof(szFileName));
673 dwShellAttributes |= SFGAO_STREAM;
674
675 // Vista+ feature: Hidden files with a leading tilde treated as super-hidden
676 // See https://devblogs.microsoft.com/oldnewthing/20170526-00/?p=96235
677 if (hasName && szFileName[0] == '~' && (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
678 dwShellAttributes |= SFGAO_HIDDEN | SFGAO_SYSTEM;
679
680 if (hasName && (pExtension = PathFindExtensionW(szFileName)))
681 {
682 CLSID clsidFile;
683 // FIXME: Cache this?
684 HRESULT hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
685 if (hr == S_OK)
686 {
687 HKEY hkey;
688 hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
689 if (SUCCEEDED(hr))
690 {
692 DWORD dwSize = sizeof(dwAttributes);
694
696 if (Status == STATUS_SUCCESS)
697 {
698 TRACE("Augmenting '%S' with dwAttributes=0x%x\n", szFileName, dwAttributes);
699 dwShellAttributes |= dwAttributes;
700 }
701 ::RegCloseKey(hkey);
702
703 // This should be presented as directory!
704 bDirectory = (dwAttributes & SFGAO_FOLDER) != 0 || dwAttributes == 0;
705 TRACE("Treating '%S' as directory!\n", szFileName);
706 }
707 }
708 }
709 }
710
711 // This is a directory
712 if (bDirectory)
713 {
714 dwShellAttributes |= (SFGAO_FOLDER | /*SFGAO_HASSUBFOLDER |*/ SFGAO_STORAGE);
715
716 // Is this a real directory?
718 {
719 dwShellAttributes |= (SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
720 }
721 }
722
724 dwShellAttributes |= SFGAO_HIDDEN | SFGAO_GHOSTED;
725
727 dwShellAttributes |= SFGAO_READONLY;
728
730 dwShellAttributes |= SFGAO_SYSTEM;
731
733 dwShellAttributes |= SFGAO_COMPRESSED;
734
736 dwShellAttributes |= SFGAO_ENCRYPTED;
737
738 if ((SFGAO_NONENUMERATED & *pdwAttributes) && (dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
739 {
741 if ((!(shcf & SHCONTF_INCLUDEHIDDEN)) || ((dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) && !(shcf & SHCONTF_INCLUDESUPERHIDDEN)))
742 dwShellAttributes |= SFGAO_NONENUMERATED;
743 }
744
745 if (SFGAO_LINK & *pdwAttributes)
746 {
748
749 if (_ILGetExtension(pidl, ext, _countof(ext)) && !lstrcmpiW(ext, L"lnk"))
750 dwShellAttributes |= SFGAO_LINK;
751 }
752
753 if (SFGAO_HASSUBFOLDER & *pdwAttributes)
754 {
755 CComPtr<IShellFolder> psf2;
756 if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
757 {
758 CComPtr<IEnumIDList> pEnumIL;
759 if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
760 {
761 if (pEnumIL->Skip(1) == S_OK)
762 dwShellAttributes |= SFGAO_HASSUBFOLDER;
763 }
764 }
765 }
766
767 *pdwAttributes = dwShellAttributes;
768
769 TRACE ("-- 0x%08x\n", *pdwAttributes);
770 return S_OK;
771}
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:1783
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:2531
#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 1453 of file CFSFolder.cpp.

1454{
1455 HKEY hKey;
1456 BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
1457 LONG lError;
1458
1459 doHide = !SHELL_GetSetting(SSF_SHOWEXTENSIONS, fShowExtensions);
1460
1461 if (!doHide)
1462 {
1464 if (*DotExt != 0)
1465 {
1467 LONG classlen = sizeof(classname);
1468 lError = RegQueryValueW(HKEY_CLASSES_ROOT, DotExt, classname, &classlen);
1469 if (lError == ERROR_SUCCESS)
1470 {
1472 if (lError == ERROR_SUCCESS)
1473 {
1474 lError = RegQueryValueExW(hKey, L"NeverShowExt", NULL, NULL, NULL, NULL);
1475 if (lError == ERROR_SUCCESS)
1476 doHide = TRUE;
1477
1479 }
1480 }
1481 }
1482 }
1483
1484 return doHide;
1485}
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:837
#define SSF_SHOWEXTENSIONS
Definition: shlobj.h:1614

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

◆ SHELL_FS_ProcessDisplayFilename()

void SHELL_FS_ProcessDisplayFilename ( LPWSTR  szPath,
DWORD  dwFlags 
)

Definition at line 1487 of file CFSFolder.cpp.

1488{
1489 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
1490 if (!(dwFlags & SHGDN_FORPARSING) &&
1491 ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
1492 if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
1494 }
1495}
BOOL SHELL_FS_HideExtension(LPCWSTR szPath)
Definition: CFSFolder.cpp:1453
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:78
#define IDS_SHV_COLUMN_NAME
Definition: resource.h:77
#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 584 of file CFSFolder.cpp.

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