ReactOS  0.4.15-dev-4916-gd519b11
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   6
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static HRESULT SHELL32_GetCLSIDForDirectory (LPCWSTR pwszDir, LPCWSTR KeyName, CLSID *pclsidFolder)
 
HKEY OpenKeyFromFileType (LPWSTR pExtension, LPCWSTR KeyName)
 
LPWSTR ExtensionFromPidl (PCUIDLIST_RELATIVE pidl)
 
HRESULT GetCLSIDForFileTypeFromExtension (LPWSTR 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)
 
LPITEMIDLIST SHELL32_CreatePidlFromBindCtx (IBindCtx *pbc, LPCWSTR path)
 
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   6

Definition at line 537 of file CFSFolder.cpp.

◆ SUPER_HIDDEN

Function Documentation

◆ CFSExtractIcon_CreateInstance()

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

Definition at line 240 of file CFSFolder.cpp.

241 {
242  CComPtr<IDefaultExtractIconInit> initIcon;
243  HRESULT hr;
244  int icon_idx = 0;
245  UINT flags = 0; // FIXME: Use it!
246  WCHAR wTemp[MAX_PATH] = L"";
247 
249  if (FAILED(hr))
250  return hr;
251 
252  if (_ILIsFolder (pidl))
253  {
255  pidl, 0, wTemp, _countof(wTemp),
256  &icon_idx,
257  &flags)))
258  {
259  initIcon->SetNormalIcon(wTemp, icon_idx);
260  // FIXME: if/when getIconLocationForFolder does something for
261  // GIL_FORSHORTCUT, code below should be uncommented. and
262  // the following line removed.
263  initIcon->SetShortcutIcon(wTemp, icon_idx);
264  }
266  pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp),
267  &icon_idx,
268  &flags)))
269  {
270  initIcon->SetDefaultIcon(wTemp, icon_idx);
271  }
272  // if (SUCCEEDED(getIconLocationForFolder(psf,
273  // pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp),
274  // &icon_idx,
275  // &flags)))
276  // {
277  // initIcon->SetShortcutIcon(wTemp, icon_idx);
278  // }
280  pidl, GIL_OPENICON, wTemp, _countof(wTemp),
281  &icon_idx,
282  &flags)))
283  {
284  initIcon->SetOpenIcon(wTemp, icon_idx);
285  }
286  }
287  else
288  {
289  LPWSTR pExtension = ExtensionFromPidl(pidl);
290  HKEY hkey = pExtension ? OpenKeyFromFileType(pExtension, L"DefaultIcon") : NULL;
291  if (!hkey)
292  WARN("Could not open DefaultIcon key!\n");
293 
294  DWORD dwSize = sizeof(wTemp);
295  if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
296  {
297  WCHAR sNum[5];
298  if (ParseFieldW (wTemp, 2, sNum, 5))
299  icon_idx = _wtoi(sNum);
300  else
301  icon_idx = 0; /* sometimes the icon number is missing */
302  ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
303  PathUnquoteSpacesW(wTemp);
304 
305  if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
306  {
307  ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
308  icon_idx = 0;
309 
310  INT ret = ExtractIconExW(wTemp, -1, NULL, NULL, 0);
311  if (ret <= 0)
312  {
313  StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
314  if (lstrcmpiW(pExtension, L".exe") == 0 || lstrcmpiW(pExtension, L".scr") == 0)
315  icon_idx = -IDI_SHELL_EXE;
316  else
317  icon_idx = -IDI_SHELL_DOCUMENT;
318  }
319  }
320 
321  initIcon->SetNormalIcon(wTemp, icon_idx);
322  }
323  else
324  {
325  initIcon->SetNormalIcon(swShell32Name, 0);
326  }
327 
328  if (hkey)
329  RegCloseKey(hkey);
330  }
331 
332  return initIcon->QueryInterface(iid, ppvOut);
333 }
HRESULT hr
Definition: shlfolder.c:183
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define WARN(fmt,...)
Definition: debug.h:112
LPWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl)
Definition: CFSFolder.cpp:48
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
#define IID_PPV_ARG(Itype, ppType)
int32_t INT
Definition: typedefs.h:58
static HRESULT getIconLocationForFolder(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
Definition: CFSFolder.cpp:164
#define ILGDN_FORPARSING
Definition: undocshell.h:68
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define L(x)
Definition: ntvdm.h:50
UINT WINAPI ExtractIconExW(LPCWSTR lpszFile, INT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIcons)
Definition: iconcache.cpp:866
if SUCCEEDED(hr)
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:1976
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY OpenKeyFromFileType(LPWSTR pExtension, LPCWSTR KeyName)
Definition: CFSFolder.cpp:18
GLbitfield flags
Definition: glext.h:7161
DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLSPEC_HIDDEN
Definition: shellord.c:116
int ret
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1461
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:524
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define IDI_SHELL_EXE
Definition: shresdef.h:526
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by CFSFolder::GetUIObjectOf().

◆ DoLoadPicture()

static HBITMAP DoLoadPicture ( LPCWSTR  pszFileName)
static

Definition at line 1841 of file CFSFolder.cpp.

1842 {
1843  // create stream from file
1844  HRESULT hr;
1845  CComPtr<IStream> pStream;
1847  FALSE, NULL, &pStream);
1848  if (FAILED(hr))
1849  return NULL;
1850 
1851  // load the picture
1852  HBITMAP hbm = NULL;
1853  CComPtr<IPicture> pPicture;
1854  OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
1855 
1856  // get the bitmap handle
1857  if (pPicture)
1858  {
1859  pPicture->get_Handle((OLE_HANDLE *)&hbm);
1860 
1861  // copy the bitmap handle
1863  }
1864 
1865  return hbm;
1866 }
HRESULT hr
Definition: shlfolder.c:183
#define FALSE
Definition: types.h:117
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1956
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
HRESULT WINAPI OleLoadPicture(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
Definition: olepicture.c:2344
#define STGM_READ
Definition: objbase.h:916
int OLE_HANDLE
Definition: olepro.idl:76
LONG HRESULT
Definition: typedefs.h:79
HRESULT WINAPI SHCreateStreamOnFileEx(LPCWSTR lpszPath, DWORD dwMode, DWORD dwAttributes, BOOL bCreate, IStream *lpTemplate, IStream **lppStream)
Definition: istream.c:401
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
const GUID IID_IPicture
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define LR_CREATEDIBSECTION
Definition: winuser.h:1092
#define NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
static HBITMAP
Definition: button.c:44

Referenced by CFSFolder::GetCustomViewInfo().

◆ ExtensionFromPidl()

LPWSTR ExtensionFromPidl ( PCUIDLIST_RELATIVE  pidl)

Definition at line 48 of file CFSFolder.cpp.

49 {
50  if (!_ILIsValue(pidl))
51  {
52  ERR("Invalid pidl!\n");
53  return NULL;
54  }
55 
56  FileStructW* pDataW = _ILGetFileStructW(pidl);
57  if (!pDataW)
58  {
59  ERR("Invalid pidl!\n");
60  return NULL;
61  }
62 
63  LPWSTR pExtension = PathFindExtensionW(pDataW->wszName);
64  if (!pExtension || *pExtension == UNICODE_NULL)
65  {
66  WARN("No extension for %S!\n", pDataW->wszName);
67  return NULL;
68  }
69  return pExtension;
70 }
WCHAR wszName[1]
Definition: shlfolder.c:1555
#define WARN(fmt,...)
Definition: debug.h:112
#define UNICODE_NULL
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:1985
#define ERR(fmt,...)
Definition: debug.h:110
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2361
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CFSExtractIcon_CreateInstance(), and GetCLSIDForFileType().

◆ GetCLSIDForFileType()

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

Definition at line 127 of file CFSFolder.cpp.

128 {
129  LPWSTR pExtension = ExtensionFromPidl(pidl);
130  if (!pExtension)
131  return S_FALSE;
132 
133  return GetCLSIDForFileTypeFromExtension(pExtension, KeyName, pclsid);
134 }
LPWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl)
Definition: CFSFolder.cpp:48
#define S_FALSE
Definition: winerror.h:2357
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
HRESULT GetCLSIDForFileTypeFromExtension(LPWSTR pExtension, LPCWSTR KeyName, CLSID *pclsid)
Definition: CFSFolder.cpp:72
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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

◆ GetCLSIDForFileTypeFromExtension()

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

Definition at line 72 of file CFSFolder.cpp.

73 {
74  HKEY hkeyProgId = OpenKeyFromFileType(pExtension, KeyName);
75  if (!hkeyProgId)
76  {
77  WARN("OpenKeyFromFileType failed for key %S\n", KeyName);
78  return S_FALSE;
79  }
80 
81  WCHAR wszCLSIDValue[CHARS_IN_GUID];
82  DWORD dwSize = sizeof(wszCLSIDValue);
83  LONG res = RegGetValueW(hkeyProgId, NULL, NULL, RRF_RT_REG_SZ, NULL, wszCLSIDValue, &dwSize);
84  RegCloseKey(hkeyProgId);
85  if (res)
86  {
87  ERR("OpenKeyFromFileType succeeded but RegGetValueW failed\n");
88  return S_FALSE;
89  }
90 
91 #if 0
92  {
94  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
95  wszCLSIDValue,
97  NULL,
98  NULL,
99  NULL);
100  if (res != ERROR_SUCCESS)
101  {
102  ERR("DropHandler extension %S not approved\n", wszName);
103  return E_ACCESSDENIED;
104  }
105  }
106 #endif
107 
109  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Blocked",
110  wszCLSIDValue,
112  NULL,
113  NULL,
114  NULL) == ERROR_SUCCESS)
115  {
116  ERR("Extension %S not approved\n", wszCLSIDValue);
117  return E_ACCESSDENIED;
118  }
119 
120  HRESULT hres = CLSIDFromString (wszCLSIDValue, pclsid);
122  return hres;
123 
124  return S_OK;
125 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WARN(fmt,...)
Definition: debug.h:112
#define CHARS_IN_GUID
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define S_FALSE
Definition: winerror.h:2357
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY OpenKeyFromFileType(LPWSTR pExtension, LPCWSTR KeyName)
Definition: CFSFolder.cpp:18
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#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 137 of file CFSFolder.cpp.

138 {
139  if (!HCR_GetIconW(L"Folder", szIconFile, NULL, cchMax, piIndex))
140  {
141  lstrcpynW(szIconFile, swShell32Name, cchMax);
142  *piIndex = -IDI_SHELL_FOLDER;
143  }
144 
145  if (uFlags & GIL_OPENICON)
146  {
147  // next icon
148  if (*piIndex < 0)
149  (*piIndex)--;
150  else
151  (*piIndex)++;
152  }
153 
154  return S_OK;
155 }
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:288
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
UINT uFlags
Definition: api.c:59
#define lstrcpynW
Definition: compat.h:597
#define L(x)
Definition: ntvdm.h:50
UINT cchMax
#define IDI_SHELL_FOLDER
Definition: shresdef.h:527
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112

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 164 of file CFSFolder.cpp.

166 {
167  DWORD dwFileAttrs;
168  WCHAR wszPath[MAX_PATH];
169  WCHAR wszIniFullPath[MAX_PATH];
170 
171  if (uFlags & GIL_DEFAULTICON)
172  goto Quit;
173 
174  // get path
175  if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
176  goto Quit;
177  if (!PathIsDirectoryW(wszPath))
178  goto Quit;
179 
180  // read-only or system folder?
181  dwFileAttrs = _ILGetFileAttributes(ILFindLastID(pidl), NULL, 0);
182  if ((dwFileAttrs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) == 0)
183  goto Quit;
184 
185  // build the full path of ini file
186  StringCchCopyW(wszIniFullPath, _countof(wszIniFullPath), wszPath);
187  PathAppendW(wszIniFullPath, L"desktop.ini");
188 
189  WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
190  if (getShellClassInfo(L"IconFile", wszValue, _countof(wszValue), wszIniFullPath))
191  {
192  // wszValue --> wszTemp
193  ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
194 
195  // wszPath + wszTemp --> wszPath
196  if (PathIsRelativeW(wszTemp))
197  PathAppendW(wszPath, wszTemp);
198  else
199  StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
200 
201  // wszPath --> szIconFile
202  GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
203 
204  *piIndex = GetPrivateProfileIntW(L".ShellClassInfo", L"IconIndex", 0, wszIniFullPath);
205  return S_OK;
206  }
207  else if (getShellClassInfo(L"CLSID", wszValue, _countof(wszValue), wszIniFullPath) &&
208  HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
209  {
210  return S_OK;
211  }
212  else if (getShellClassInfo(L"CLSID2", wszValue, _countof(wszValue), wszIniFullPath) &&
213  HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
214  {
215  return S_OK;
216  }
217  else if (getShellClassInfo(L"IconResource", wszValue, _countof(wszValue), wszIniFullPath))
218  {
219  // wszValue --> wszTemp
220  ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
221 
222  // parse the icon location
223  *piIndex = PathParseIconLocationW(wszTemp);
224 
225  // wszPath + wszTemp --> wszPath
226  if (PathIsRelativeW(wszTemp))
227  PathAppendW(wszPath, wszTemp);
228  else
229  StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
230 
231  // wszPath --> szIconFile
232  GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
233  return S_OK;
234  }
235 
236 Quit:
237  return getDefaultIconLocation(szIconFile, cchMax, piIndex, uFlags);
238 }
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1722
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1578
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2606
static HRESULT getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
Definition: CFSFolder.cpp:137
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:288
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
static BOOL getShellClassInfo(LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
Definition: CFSFolder.cpp:158
UINT uFlags
Definition: api.c:59
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
UINT WINAPI GetPrivateProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val, LPCWSTR filename)
Definition: profile.c:1297
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT cchMax
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519

Referenced by CFSExtractIcon_CreateInstance().

◆ getShellClassInfo()

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

Definition at line 158 of file CFSFolder.cpp.

159 {
160  return GetPrivateProfileStringW(L".ShellClassInfo", Entry, NULL, pszValue, cchValueLen, IniFile);
161 }
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define L(x)
Definition: ntvdm.h:50
#define NULL
Definition: types.h:112
base of all file and directory entries
Definition: entries.h:82

Referenced by getIconLocationForFolder().

◆ OpenKeyFromFileType()

HKEY OpenKeyFromFileType ( LPWSTR  pExtension,
LPCWSTR  KeyName 
)

Definition at line 18 of file CFSFolder.cpp.

19 {
20  HKEY hkey;
21 
23  DWORD dwSize = sizeof(FullName);
24  wsprintf(FullName, L"%s\\%s", pExtension, KeyName);
25 
27  if (!res)
28  return hkey;
29 
31  if (res)
32  {
33  WARN("Failed to get progid for extension %S (%x), error %d\n", pExtension, pExtension, res);
34  return NULL;
35  }
36 
37  wcscat(FullName, L"\\");
39 
40  hkey = NULL;
42  if (res)
43  WARN("Could not open key %S for extension %S\n", KeyName, pExtension);
44 
45  return hkey;
46 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
#define KEY_READ
Definition: nt_native.h:1023
#define WARN(fmt,...)
Definition: debug.h:112
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1648
_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 NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define wsprintf
Definition: winuser.h:5845
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by CFSExtractIcon_CreateInstance(), and GetCLSIDForFileTypeFromExtension().

◆ SHELL32_CreatePidlFromBindCtx()

LPITEMIDLIST SHELL32_CreatePidlFromBindCtx ( IBindCtx pbc,
LPCWSTR  path 
)

Definition at line 546 of file CFSFolder.cpp.

547 {
549  LPITEMIDLIST pidl = NULL;
550  IUnknown *param = NULL;
551  WIN32_FIND_DATAW wfd;
552  HRESULT r;
553 
554  TRACE("%p %s\n", pbc, debugstr_w(path));
555 
556  if (!pbc)
557  return NULL;
558 
559  /* see if the caller bound File System Bind Data */
560  r = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, &param);
561  if (FAILED(r))
562  return NULL;
563 
564  r = param->QueryInterface(IID_PPV_ARG(IFileSystemBindData,&fsbd));
565  if (SUCCEEDED(r))
566  {
567  r = fsbd->GetFindData(&wfd);
568  if (SUCCEEDED(r))
569  {
570  lstrcpynW(&wfd.cFileName[0], path, MAX_PATH);
571  pidl = _ILCreateFromFindDataW(&wfd);
572  }
573  fsbd->Release();
574  }
575 
576  return pidl;
577 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static LPOLESTR
Definition: stg_prop.c:27
HRESULT GetFindData([out] WIN32_FIND_DATAW *pfd)
#define IID_PPV_ARG(Itype, ppType)
#define lstrcpynW
Definition: compat.h:597
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
ULONG Release()
HRESULT GetObjectParam([in] LPOLESTR pszKey, [out] IUnknown **ppunk)
static IFileSystemBindData fsbd
Definition: shlfolder.c:4674
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
#define NULL
Definition: types.h:112
LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *wfd)
Definition: pidl.c:1741
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by CFSFolder::ParseDisplayName(), and CDesktopFolder::ParseDisplayName().

◆ SHELL32_GetCLSIDForDirectory()

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

Definition at line 579 of file CFSFolder.cpp.

580 {
581  WCHAR wszCLSIDValue[CHARS_IN_GUID];
582  WCHAR wszDesktopIni[MAX_PATH];
583 
584  StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
585  StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
586 
587  if (GetPrivateProfileStringW(L".ShellClassInfo",
588  KeyName,
589  L"",
590  wszCLSIDValue,
592  wszDesktopIni))
593  {
594  return CLSIDFromString(wszCLSIDValue, pclsidFolder);
595  }
596  return E_FAIL;
597 }
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define CHARS_IN_GUID
#define E_FAIL
Definition: ddrawi.h:102
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338

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

◆ SHELL32_GetFSItemAttributes()

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

Definition at line 599 of file CFSFolder.cpp.

600 {
601  DWORD dwFileAttributes, dwShellAttributes;
602 
603  if (!_ILIsFolder(pidl) && !_ILIsValue(pidl))
604  {
605  ERR("Got wrong type of pidl!\n");
606  *pdwAttributes &= SFGAO_CANLINK;
607  return S_OK;
608  }
609 
611 
612  /* Set common attributes */
613  dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
614  SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
615 
616  BOOL bDirectory = (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
617 
618  if (!bDirectory)
619  {
620  // https://git.reactos.org/?p=reactos.git;a=blob;f=dll/shellext/zipfldr/res/zipfldr.rgs;hb=032b5aacd233cd7b83ab6282aad638c161fdc400#l9
621  WCHAR szFileName[MAX_PATH];
622  LPWSTR pExtension;
623 
624  if (_ILSimpleGetTextW(pidl, szFileName, _countof(szFileName)) && (pExtension = PathFindExtensionW(szFileName)))
625  {
626  CLSID clsidFile;
627  // FIXME: Cache this?
628  HRESULT hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
629  if (hr == S_OK)
630  {
631  HKEY hkey;
632  hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
633  if (SUCCEEDED(hr))
634  {
635  DWORD dwAttributes = 0;
636  DWORD dwSize = sizeof(dwAttributes);
637  LSTATUS Status;
638 
639  Status = SHRegGetValueW(hkey, NULL, L"Attributes", RRF_RT_REG_DWORD, NULL, &dwAttributes, &dwSize);
640  if (Status == STATUS_SUCCESS)
641  {
642  TRACE("Augmenting '%S' with dwAttributes=0x%x\n", szFileName, dwAttributes);
643  dwShellAttributes |= dwAttributes;
644  }
645  ::RegCloseKey(hkey);
646 
647  // This should be presented as directory!
648  bDirectory = TRUE;
649  TRACE("Treating '%S' as directory!\n", szFileName);
650  }
651  }
652  }
653  }
654 
655  // This is a directory
656  if (bDirectory)
657  {
658  dwShellAttributes |= (SFGAO_FOLDER | /*SFGAO_HASSUBFOLDER |*/ SFGAO_STORAGE);
659 
660  // Is this a real directory?
662  {
663  dwShellAttributes |= (SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
664  }
665  }
666  else
667  {
668  dwShellAttributes |= SFGAO_STREAM;
669  }
670 
672  dwShellAttributes |= SFGAO_HIDDEN;
673 
675  dwShellAttributes |= SFGAO_READONLY;
676 
677  if (SFGAO_LINK & *pdwAttributes)
678  {
679  char ext[MAX_PATH];
680 
681  if (_ILGetExtension(pidl, ext, MAX_PATH) && !lstrcmpiA(ext, "lnk"))
682  dwShellAttributes |= SFGAO_LINK;
683  }
684 
685  if (SFGAO_HASSUBFOLDER & *pdwAttributes)
686  {
687  CComPtr<IShellFolder> psf2;
688  if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
689  {
690  CComPtr<IEnumIDList> pEnumIL;
691  if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
692  {
693  if (pEnumIL->Skip(1) == S_OK)
694  dwShellAttributes |= SFGAO_HASSUBFOLDER;
695  }
696  }
697  }
698 
699  *pdwAttributes = dwShellAttributes;
700 
701  TRACE ("-- 0x%08x\n", *pdwAttributes);
702  return S_OK;
703 }
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2606
HRESULT hr
Definition: shlfolder.c:183
#define TRUE
Definition: types.h:120
#define IID_PPV_ARG(Itype, ppType)
DWORD dwAttributes
Definition: vdmdbg.h:34
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
if SUCCEEDED(hr)
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:1976
char ext[3]
Definition: mkdosfs.c:358
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2487
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2107
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID, LPCWSTR, BOOL, BOOL, PHKEY)
Definition: reg.c:2422
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
unsigned long DWORD
Definition: ntddk_ex.h:95
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:1985
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)
HRESULT GetCLSIDForFileTypeFromExtension(LPWSTR pExtension, LPCWSTR KeyName, CLSID *pclsid)
Definition: CFSFolder.cpp:72
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:52
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define NULL
Definition: types.h:112
DWORD dwFileAttributes
#define STATUS_SUCCESS
Definition: shellext.h:65
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RRF_RT_REG_DWORD
Definition: driver.c:578
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by CFSFolder::GetAttributesOf(), and CFSFolder::ParseDisplayName().

◆ SHELL_FS_HideExtension()

BOOL SHELL_FS_HideExtension ( LPCWSTR  szPath)

Definition at line 1272 of file CFSFolder.cpp.

1273 {
1274  HKEY hKey;
1275  DWORD dwData, dwDataSize = sizeof(DWORD);
1276  BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
1277  LONG lError;
1278 
1279  lError = RegCreateKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
1280  0, NULL, 0, KEY_ALL_ACCESS, NULL,
1281  &hKey, NULL);
1282  if (lError == ERROR_SUCCESS)
1283  {
1284  lError = RegQueryValueExW(hKey, L"HideFileExt", NULL, NULL, (LPBYTE)&dwData, &dwDataSize);
1285  if (lError == ERROR_SUCCESS)
1286  doHide = dwData;
1287  RegCloseKey(hKey);
1288  }
1289 
1290  if (!doHide)
1291  {
1292  LPCWSTR DotExt = PathFindExtensionW(szPath);
1293  if (*DotExt != 0)
1294  {
1296  LONG classlen = sizeof(classname);
1297  lError = RegQueryValueW(HKEY_CLASSES_ROOT, DotExt, classname, &classlen);
1298  if (lError == ERROR_SUCCESS)
1299  {
1301  if (lError == ERROR_SUCCESS)
1302  {
1303  lError = RegQueryValueExW(hKey, L"NeverShowExt", NULL, NULL, NULL, NULL);
1304  if (lError == ERROR_SUCCESS)
1305  doHide = TRUE;
1306 
1307  RegCloseKey(hKey);
1308  }
1309  }
1310  }
1311  }
1312 
1313  return doHide;
1314 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static HANDLE ULONG_PTR dwData
Definition: file.c:35
WCHAR classname[128]
Definition: startup.c:15
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4258
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
LPCWSTR szPath
Definition: env.c:37
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegCloseKey(hKey)
Definition: registry.h:47

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

◆ SHELL_FS_ProcessDisplayFilename()

void SHELL_FS_ProcessDisplayFilename ( LPWSTR  szPath,
DWORD  dwFlags 
)

Definition at line 1316 of file CFSFolder.cpp.

1317 {
1318  /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
1319  if (!(dwFlags & SHGDN_FORPARSING) &&
1320  ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
1321  if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
1323  }
1324 }
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
BOOL SHELL_FS_HideExtension(LPCWSTR szPath)
Definition: CFSFolder.cpp:1272
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPCWSTR szPath
Definition: env.c:37

Referenced by CFSFolder::GetDisplayNameOf().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ GenericSFHeader