ReactOS 0.4.15-dev-7906-g1b85a5f
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)
 
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 540 of file CFSFolder.cpp.

◆ SUPER_HIDDEN

Function Documentation

◆ CFSExtractIcon_CreateInstance()

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

Definition at line 243 of file CFSFolder.cpp.

244{
245 CComPtr<IDefaultExtractIconInit> initIcon;
246 HRESULT hr;
247 int icon_idx = 0;
248 UINT flags = 0; // FIXME: Use it!
249 WCHAR wTemp[MAX_PATH] = L"";
250
252 if (FAILED(hr))
253 return hr;
254
255 if (_ILIsFolder (pidl))
256 {
258 pidl, 0, wTemp, _countof(wTemp),
259 &icon_idx,
260 &flags)))
261 {
262 initIcon->SetNormalIcon(wTemp, icon_idx);
263 // FIXME: if/when getIconLocationForFolder does something for
264 // GIL_FORSHORTCUT, code below should be uncommented. and
265 // the following line removed.
266 initIcon->SetShortcutIcon(wTemp, icon_idx);
267 }
269 pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp),
270 &icon_idx,
271 &flags)))
272 {
273 initIcon->SetDefaultIcon(wTemp, icon_idx);
274 }
275 // if (SUCCEEDED(getIconLocationForFolder(psf,
276 // pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp),
277 // &icon_idx,
278 // &flags)))
279 // {
280 // initIcon->SetShortcutIcon(wTemp, icon_idx);
281 // }
283 pidl, GIL_OPENICON, wTemp, _countof(wTemp),
284 &icon_idx,
285 &flags)))
286 {
287 initIcon->SetOpenIcon(wTemp, icon_idx);
288 }
289 }
290 else
291 {
292 LPWSTR pExtension = ExtensionFromPidl(pidl);
293 HKEY hkey = pExtension ? OpenKeyFromFileType(pExtension, L"DefaultIcon") : NULL;
294 if (!hkey)
295 WARN("Could not open DefaultIcon key!\n");
296
297 DWORD dwSize = sizeof(wTemp);
298 if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
299 {
300 WCHAR sNum[5];
301 if (ParseFieldW (wTemp, 2, sNum, 5))
302 icon_idx = _wtoi(sNum);
303 else
304 icon_idx = 0; /* sometimes the icon number is missing */
305 ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
306 PathUnquoteSpacesW(wTemp);
307
308 if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
309 {
310 ILGetDisplayNameExW(psf, pidl, wTemp, ILGDN_FORPARSING);
311 icon_idx = 0;
312
313 INT ret = PrivateExtractIconsW(wTemp, 0, 0, 0, NULL, NULL, 0, 0);
314 if (ret <= 0)
315 {
316 StringCbCopyW(wTemp, sizeof(wTemp), swShell32Name);
317 if (lstrcmpiW(pExtension, L".exe") == 0 || lstrcmpiW(pExtension, L".scr") == 0)
318 icon_idx = -IDI_SHELL_EXE;
319 else
320 icon_idx = -IDI_SHELL_DOCUMENT;
321 }
322 }
323
324 initIcon->SetNormalIcon(wTemp, icon_idx);
325 }
326 else
327 {
328 initIcon->SetNormalIcon(swShell32Name, 0);
329 }
330
331 if (hkey)
332 RegCloseKey(hkey);
333 }
334
335 return initIcon->QueryInterface(iid, ppvOut);
336}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define WARN(fmt,...)
Definition: debug.h:112
#define RegCloseKey(hKey)
Definition: registry.h:49
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
static HRESULT getIconLocationForFolder(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
Definition: CFSFolder.cpp:167
HKEY OpenKeyFromFileType(LPWSTR pExtension, LPCWSTR KeyName)
Definition: CFSFolder.cpp:18
LPWSTR ExtensionFromPidl(PCUIDLIST_RELATIVE pidl)
Definition: CFSFolder.cpp:48
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1034
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1461
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
GLbitfield flags
Definition: glext.h:7161
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
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:2020
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:553
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:551
#define _countof(array)
Definition: sndvol32.h:68
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:70
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
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CFSFolder::GetUIObjectOf().

◆ DoLoadPicture()

static HBITMAP DoLoadPicture ( LPCWSTR  pszFileName)
static

Definition at line 1909 of file CFSFolder.cpp.

1910{
1911 // create stream from file
1912 HRESULT hr;
1913 CComPtr<IStream> pStream;
1915 FALSE, NULL, &pStream);
1916 if (FAILED(hr))
1917 return NULL;
1918
1919 // load the picture
1920 HBITMAP hbm = NULL;
1921 CComPtr<IPicture> pPicture;
1922 OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
1923
1924 // get the bitmap handle
1925 if (pPicture)
1926 {
1927 pPicture->get_Handle((OLE_HANDLE *)&hbm);
1928
1929 // copy the bitmap handle
1931 }
1932
1933 return hbm;
1934}
#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:1098
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:1987

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}
#define ERR(fmt,...)
Definition: debug.h:110
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
#define UNICODE_NULL
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2405
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2029
WCHAR wszName[1]
Definition: shlfolder.c:1555

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}
HRESULT GetCLSIDForFileTypeFromExtension(LPWSTR pExtension, LPCWSTR KeyName, CLSID *pclsid)
Definition: CFSFolder.cpp:72
_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()

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,
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}
#define CHARS_IN_GUID
#define ERROR_SUCCESS
Definition: deptool.c:10
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
#define RRF_RT_REG_SZ
Definition: driver.c:575
GLuint res
Definition: glext.h:9613
#define S_OK
Definition: intsafe.h:52
HRESULT hres
Definition: protocol.c:465
long LONG
Definition: pedump.c:60
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

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

◆ getDefaultIconLocation()

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

Definition at line 137 of file CFSFolder.cpp.

138{
139 if (!HLM_GetIconW(IDI_SHELL_FOLDER - 1, szIconFile, cchMax, piIndex))
140 {
141 if (!HCR_GetIconW(L"Folder", szIconFile, NULL, cchMax, piIndex))
142 {
143 StringCchCopyW(szIconFile, cchMax, swShell32Name);
144 *piIndex = -IDI_SHELL_FOLDER;
145 }
146 }
147
148 if (uFlags & GIL_OPENICON)
149 {
150 // next icon
151 if (*piIndex < 0)
152 (*piIndex)--;
153 else
154 (*piIndex)++;
155 }
156
157 return S_OK;
158}
UINT cchMax
#define IDI_SHELL_FOLDER
Definition: treeview.c:36
UINT uFlags
Definition: api.c:59
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:291
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 167 of file CFSFolder.cpp.

169{
170 DWORD dwFileAttrs;
171 WCHAR wszPath[MAX_PATH];
172 WCHAR wszIniFullPath[MAX_PATH];
173
174 if (uFlags & GIL_DEFAULTICON)
175 goto Quit;
176
177 // get path
178 if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
179 goto Quit;
180 if (!PathIsDirectoryW(wszPath))
181 goto Quit;
182
183 // read-only or system folder?
184 dwFileAttrs = _ILGetFileAttributes(ILFindLastID(pidl), NULL, 0);
185 if ((dwFileAttrs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) == 0)
186 goto Quit;
187
188 // build the full path of ini file
189 StringCchCopyW(wszIniFullPath, _countof(wszIniFullPath), wszPath);
190 PathAppendW(wszIniFullPath, L"desktop.ini");
191
192 WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
193 if (getShellClassInfo(L"IconFile", wszValue, _countof(wszValue), wszIniFullPath))
194 {
195 // wszValue --> wszTemp
196 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
197
198 // wszPath + wszTemp --> wszPath
199 if (PathIsRelativeW(wszTemp))
200 PathAppendW(wszPath, wszTemp);
201 else
202 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
203
204 // wszPath --> szIconFile
205 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
206
207 *piIndex = GetPrivateProfileIntW(L".ShellClassInfo", L"IconIndex", 0, wszIniFullPath);
208 return S_OK;
209 }
210 else if (getShellClassInfo(L"CLSID", wszValue, _countof(wszValue), wszIniFullPath) &&
211 HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
212 {
213 return S_OK;
214 }
215 else if (getShellClassInfo(L"CLSID2", wszValue, _countof(wszValue), wszIniFullPath) &&
216 HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
217 {
218 return S_OK;
219 }
220 else if (getShellClassInfo(L"IconResource", wszValue, _countof(wszValue), wszIniFullPath))
221 {
222 // wszValue --> wszTemp
223 ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
224
225 // parse the icon location
226 *piIndex = PathParseIconLocationW(wszTemp);
227
228 // wszPath + wszTemp --> wszPath
229 if (PathIsRelativeW(wszTemp))
230 PathAppendW(wszPath, wszTemp);
231 else
232 StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
233
234 // wszPath --> szIconFile
235 GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
236 return S_OK;
237 }
238
239Quit:
240 return getDefaultIconLocation(szIconFile, cchMax, piIndex, uFlags);
241}
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:161
static HRESULT getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
Definition: CFSFolder.cpp:137
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1092
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define PathAppendW
Definition: pathcch.h:309
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2650

Referenced by CFSExtractIcon_CreateInstance().

◆ getShellClassInfo()

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

Definition at line 161 of file CFSFolder.cpp.

162{
163 return GetPrivateProfileStringW(L".ShellClassInfo", Entry, NULL, pszValue, cchValueLen, IniFile);
164}
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().

◆ 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}
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
#define KEY_READ
Definition: nt_native.h:1023
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define wsprintf
Definition: winuser.h:5865
_In_ PSTRING FullName
Definition: rtlfuncs.h:1648

Referenced by CFSExtractIcon_CreateInstance(), and GetCLSIDForFileTypeFromExtension().

◆ SHELL32_GetCLSIDForDirectory()

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

Definition at line 542 of file CFSFolder.cpp.

543{
544 WCHAR wszCLSIDValue[CHARS_IN_GUID];
545 WCHAR wszDesktopIni[MAX_PATH];
546
547 StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
548 StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
549
550 if (GetPrivateProfileStringW(L".ShellClassInfo",
551 KeyName,
552 L"",
553 wszCLSIDValue,
555 wszDesktopIni))
556 {
557 return CLSIDFromString(wszCLSIDValue, pclsidFolder);
558 }
559 return E_FAIL;
560}
#define E_FAIL
Definition: ddrawi.h:102
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 562 of file CFSFolder.cpp.

563{
564 DWORD dwFileAttributes, dwShellAttributes;
565
566 if (!_ILIsFolder(pidl) && !_ILIsValue(pidl))
567 {
568 ERR("Got wrong type of pidl!\n");
569 *pdwAttributes &= SFGAO_CANLINK;
570 return S_OK;
571 }
572
574
575 /* Set common attributes */
576 dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
577 SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
578
579 BOOL bDirectory = (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
580
581 if (!bDirectory)
582 {
583 // https://git.reactos.org/?p=reactos.git;a=blob;f=dll/shellext/zipfldr/res/zipfldr.rgs;hb=032b5aacd233cd7b83ab6282aad638c161fdc400#l9
584 WCHAR szFileName[MAX_PATH];
585 LPWSTR pExtension;
586
587 if (_ILSimpleGetTextW(pidl, szFileName, _countof(szFileName)) && (pExtension = PathFindExtensionW(szFileName)))
588 {
589 CLSID clsidFile;
590 // FIXME: Cache this?
591 HRESULT hr = GetCLSIDForFileTypeFromExtension(pExtension, L"CLSID", &clsidFile);
592 if (hr == S_OK)
593 {
594 HKEY hkey;
595 hr = SHRegGetCLSIDKeyW(clsidFile, L"ShellFolder", FALSE, FALSE, &hkey);
596 if (SUCCEEDED(hr))
597 {
599 DWORD dwSize = sizeof(dwAttributes);
601
603 if (Status == STATUS_SUCCESS)
604 {
605 TRACE("Augmenting '%S' with dwAttributes=0x%x\n", szFileName, dwAttributes);
606 dwShellAttributes |= dwAttributes;
607 }
608 ::RegCloseKey(hkey);
609
610 // This should be presented as directory!
611 bDirectory = TRUE;
612 TRACE("Treating '%S' as directory!\n", szFileName);
613 }
614 }
615 }
616 }
617
618 // This is a directory
619 if (bDirectory)
620 {
621 dwShellAttributes |= (SFGAO_FOLDER | /*SFGAO_HASSUBFOLDER |*/ SFGAO_STORAGE);
622
623 // Is this a real directory?
625 {
626 dwShellAttributes |= (SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR);
627 }
628 }
629 else
630 {
631 dwShellAttributes |= SFGAO_STREAM;
632 }
633
635 dwShellAttributes |= SFGAO_HIDDEN;
636
638 dwShellAttributes |= SFGAO_READONLY;
639
640 if (SFGAO_LINK & *pdwAttributes)
641 {
642 char ext[MAX_PATH];
643
644 if (_ILGetExtension(pidl, ext, MAX_PATH) && !lstrcmpiA(ext, "lnk"))
645 dwShellAttributes |= SFGAO_LINK;
646 }
647
648 if (SFGAO_HASSUBFOLDER & *pdwAttributes)
649 {
650 CComPtr<IShellFolder> psf2;
651 if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
652 {
653 CComPtr<IEnumIDList> pEnumIL;
654 if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
655 {
656 if (pEnumIL->Skip(1) == S_OK)
657 dwShellAttributes |= SFGAO_HASSUBFOLDER;
658 }
659 }
660 }
661
662 *pdwAttributes = dwShellAttributes;
663
664 TRACE ("-- 0x%08x\n", *pdwAttributes);
665 return S_OK;
666}
DWORD dwFileAttributes
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define TRUE
Definition: types.h:120
static const WCHAR *const ext[]
Definition: module.c:53
#define RRF_RT_REG_DWORD
Definition: driver.c:578
HRESULT WINAPI SHRegGetCLSIDKeyW(REFGUID, LPCWSTR, BOOL, BOOL, PHKEY)
Definition: reg.c:2422
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)
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2531
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2151
#define STATUS_SUCCESS
Definition: shellext.h:65
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 1330 of file CFSFolder.cpp.

1331{
1332 HKEY hKey;
1333 DWORD dwData, dwDataSize = sizeof(DWORD);
1334 BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
1335 LONG lError;
1336
1337 lError = RegCreateKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
1338 0, NULL, 0, KEY_ALL_ACCESS, NULL,
1339 &hKey, NULL);
1340 if (lError == ERROR_SUCCESS)
1341 {
1342 lError = RegQueryValueExW(hKey, L"HideFileExt", NULL, NULL, (LPBYTE)&dwData, &dwDataSize);
1343 if (lError == ERROR_SUCCESS)
1344 doHide = dwData;
1346 }
1347
1348 if (!doHide)
1349 {
1351 if (*DotExt != 0)
1352 {
1354 LONG classlen = sizeof(classname);
1355 lError = RegQueryValueW(HKEY_CLASSES_ROOT, DotExt, classname, &classlen);
1356 if (lError == ERROR_SUCCESS)
1357 {
1359 if (lError == ERROR_SUCCESS)
1360 {
1361 lError = RegQueryValueExW(hKey, L"NeverShowExt", NULL, NULL, NULL, NULL);
1362 if (lError == ERROR_SUCCESS)
1363 doHide = TRUE;
1364
1366 }
1367 }
1368 }
1369 }
1370
1371 return doHide;
1372}
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:1096
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
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define DWORD
Definition: nt_native.h:44
WCHAR classname[128]
Definition: startup.c:15
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

◆ SHELL_FS_ProcessDisplayFilename()

void SHELL_FS_ProcessDisplayFilename ( LPWSTR  szPath,
DWORD  dwFlags 
)

Definition at line 1374 of file CFSFolder.cpp.

1375{
1376 /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
1377 if (!(dwFlags & SHGDN_FORPARSING) &&
1378 ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
1379 if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
1381 }
1382}
BOOL SHELL_FS_HideExtension(LPCWSTR szPath)
Definition: CFSFolder.cpp:1330
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by CFSFolder::GetDisplayNameOf().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ GenericSFHeader

const shvheader GenericSFHeader[]
static
Initial value:

Definition at line 531 of file CFSFolder.cpp.

Referenced by CFSFolder::GetDefaultColumnState(), and CFSFolder::GetDetailsOf().