ReactOS  0.4.13-dev-257-gfabbd7c
CFSFolder.cpp
Go to the documentation of this file.
1 
2 /*
3  * file system folder
4  *
5  * Copyright 1997 Marcus Meissner
6  * Copyright 1998, 1999, 2002 Juergen Schmied
7  * Copyright 2019 Katayama Hirofumi MZ
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <precomp.h>
25 
27 
29 {
30  HKEY hkey;
31 
32  if (!_ILIsValue(pidl))
33  {
34  ERR("Invalid pidl!\n");
35  return NULL;
36  }
37 
38  FileStructW* pDataW = _ILGetFileStructW(pidl);
39  if (!pDataW)
40  {
41  ERR("Invalid pidl!\n");
42  return NULL;
43  }
44 
45  LPWSTR pExtension = PathFindExtensionW(pDataW->wszName);
46  if (!pExtension || *pExtension == NULL)
47  {
48  WARN("No extension for %S!\n", pDataW->wszName);
49  return NULL;
50  }
51 
53  DWORD dwSize = sizeof(FullName);
54  wsprintf(FullName, L"%s\\%s", pExtension, KeyName);
55 
57  if (!res)
58  return hkey;
59 
61  if (res)
62  {
63  WARN("Failed to get progid for file %S, extension %S (%x), address %x, pidl: %x, error %d\n", pDataW->wszName, pExtension, pExtension, &dwSize, pidl, res);
64  return NULL;
65  }
66 
67  wcscat(FullName, L"\\");
69 
70  hkey = NULL;
72  if (res)
73  WARN("Could not open key %S for extension %S\n", KeyName, pExtension);
74 
75  return hkey;
76 }
77 
79 {
80  HKEY hkeyProgId = OpenKeyFromFileType(pidl, KeyName);
81  if (!hkeyProgId)
82  {
83  WARN("OpenKeyFromFileType failed for key %S\n", KeyName);
84  return S_FALSE;
85  }
86 
87  WCHAR wszCLSIDValue[CHARS_IN_GUID];
88  DWORD dwSize = sizeof(wszCLSIDValue);
89  LONG res = RegGetValueW(hkeyProgId, NULL, NULL, RRF_RT_REG_SZ, NULL, wszCLSIDValue, &dwSize);
90  RegCloseKey(hkeyProgId);
91  if (res)
92  {
93  ERR("OpenKeyFromFileType succeeded but RegGetValueW failed\n");
94  return S_FALSE;
95  }
96 
97 #if 0
98  {
100  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved",
101  wszCLSIDValue,
103  NULL,
104  NULL,
105  NULL);
106  if (res != ERROR_SUCCESS)
107  {
108  ERR("DropHandler extension %S not approved\n", wszName);
109  return E_ACCESSDENIED;
110  }
111  }
112 #endif
113 
115  L"Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Blocked",
116  wszCLSIDValue,
118  NULL,
119  NULL,
120  NULL) == ERROR_SUCCESS)
121  {
122  ERR("Extension %S not approved\n", wszCLSIDValue);
123  return E_ACCESSDENIED;
124  }
125 
126  HRESULT hres = CLSIDFromString (wszCLSIDValue, pclsid);
128  return hres;
129 
130  return S_OK;
131 }
132 
133 static HRESULT
134 getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
135 {
136  static const WCHAR folder[] = { 'F', 'o', 'l', 'd', 'e', 'r', 0 };
137 
138  if (!HCR_GetIconW(folder, szIconFile, NULL, cchMax, piIndex))
139  {
140  lstrcpynW(szIconFile, swShell32Name, cchMax);
141  *piIndex = -IDI_SHELL_FOLDER;
142  }
143 
144  if (uFlags & GIL_OPENICON)
145  {
146  // next icon
147  if (*piIndex < 0)
148  (*piIndex)--;
149  else
150  (*piIndex)++;
151  }
152 
153  return S_OK;
154 }
155 
156 static const WCHAR s_shellClassInfo[] = { '.', 'S', 'h', 'e', 'l', 'l', 'C', 'l', 'a', 's', 's', 'I', 'n', 'f', 'o', 0 };
157 
158 static BOOL
159 getShellClassInfo(LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
160 {
161  return GetPrivateProfileStringW(s_shellClassInfo, Entry, NULL, pszValue, cchValueLen, IniFile);
162 }
163 
164 static HRESULT
166  LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
167 {
168  DWORD dwFileAttrs;
169  WCHAR wszPath[MAX_PATH];
170  WCHAR wszIniFullPath[MAX_PATH];
171  static const WCHAR iconFile[] = { 'I', 'c', 'o', 'n', 'F', 'i', 'l', 'e', 0 };
172  static const WCHAR clsid[] = { 'C', 'L', 'S', 'I', 'D', 0 };
173  static const WCHAR clsid2[] = { 'C', 'L', 'S', 'I', 'D', '2', 0 };
174  static const WCHAR iconIndex[] = { 'I', 'c', 'o', 'n', 'I', 'n', 'd', 'e', 'x', 0 };
175  static const WCHAR iconResource[] = { 'I', 'c', 'o', 'n', 'R', 'e', 's', 'o', 'u', 'r', 'c', 'e', 0 };
176  static const WCHAR wszDesktopIni[] = { 'd','e','s','k','t','o','p','.','i','n','i',0 };
177 
178  if (uFlags & GIL_DEFAULTICON)
179  goto Quit;
180 
181  // get path
182  if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
183  goto Quit;
184  if (!PathIsDirectoryW(wszPath))
185  goto Quit;
186 
187  // read-only or system folder?
188  dwFileAttrs = _ILGetFileAttributes(ILFindLastID(pidl), NULL, 0);
189  if ((dwFileAttrs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) == 0)
190  goto Quit;
191 
192  // build the full path of ini file
193  StringCchCopyW(wszIniFullPath, _countof(wszIniFullPath), wszPath);
194  PathAppendW(wszIniFullPath, wszDesktopIni);
195 
196  WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
197  if (getShellClassInfo(iconFile, wszValue, _countof(wszValue), wszIniFullPath))
198  {
199  // wszValue --> wszTemp
200  ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
201 
202  // wszPath + wszTemp --> wszPath
203  if (PathIsRelativeW(wszTemp))
204  PathAppendW(wszPath, wszTemp);
205  else
206  StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
207 
208  // wszPath --> szIconFile
209  GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
210 
211  *piIndex = GetPrivateProfileIntW(s_shellClassInfo, iconIndex, 0, wszIniFullPath);
212  return S_OK;
213  }
214  else if (getShellClassInfo(clsid, wszValue, _countof(wszValue), wszIniFullPath) &&
215  HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
216  {
217  return S_OK;
218  }
219  else if (getShellClassInfo(clsid2, wszValue, _countof(wszValue), wszIniFullPath) &&
220  HCR_GetIconW(wszValue, szIconFile, NULL, cchMax, piIndex))
221  {
222  return S_OK;
223  }
224  else if (getShellClassInfo(iconResource, wszValue, _countof(wszValue), wszIniFullPath))
225  {
226  // wszValue --> wszTemp
227  ExpandEnvironmentStringsW(wszValue, wszTemp, _countof(wszTemp));
228 
229  // parse the icon location
230  *piIndex = PathParseIconLocationW(wszTemp);
231 
232  // wszPath + wszTemp --> wszPath
233  if (PathIsRelativeW(wszTemp))
234  PathAppendW(wszPath, wszTemp);
235  else
236  StringCchCopyW(wszPath, _countof(wszPath), wszTemp);
237 
238  // wszPath --> szIconFile
239  GetFullPathNameW(wszPath, cchMax, szIconFile, NULL);
240  return S_OK;
241  }
242 
243 Quit:
244  return getDefaultIconLocation(szIconFile, cchMax, piIndex, uFlags);
245 }
246 
248 {
249  CComPtr<IDefaultExtractIconInit> initIcon;
250  HRESULT hr;
251  int icon_idx = 0;
252  UINT flags = 0; // FIXME: Use it!
253  WCHAR wTemp[MAX_PATH] = L"";
254 
256  if (FAILED(hr))
257  return hr;
258 
259  if (_ILIsFolder (pidl))
260  {
262  pidl, 0, wTemp, _countof(wTemp),
263  &icon_idx,
264  &flags)))
265  {
266  initIcon->SetNormalIcon(wTemp, icon_idx);
267  // FIXME: if/when getIconLocationForFolder does something for
268  // GIL_FORSHORTCUT, code below should be uncommented. and
269  // the following line removed.
270  initIcon->SetShortcutIcon(wTemp, icon_idx);
271  }
273  pidl, GIL_DEFAULTICON, wTemp, _countof(wTemp),
274  &icon_idx,
275  &flags)))
276  {
277  initIcon->SetDefaultIcon(wTemp, icon_idx);
278  }
279  // if (SUCCEEDED(getIconLocationForFolder(psf,
280  // pidl, GIL_FORSHORTCUT, wTemp, _countof(wTemp),
281  // &icon_idx,
282  // &flags)))
283  // {
284  // initIcon->SetShortcutIcon(wTemp, icon_idx);
285  // }
287  pidl, GIL_OPENICON, wTemp, _countof(wTemp),
288  &icon_idx,
289  &flags)))
290  {
291  initIcon->SetOpenIcon(wTemp, icon_idx);
292  }
293  }
294  else
295  {
296  HKEY hkey = OpenKeyFromFileType(pidl, L"DefaultIcon");
297  if (!hkey)
298  WARN("Could not open DefaultIcon key!\n");
299 
300  DWORD dwSize = sizeof(wTemp);
301  if (hkey && !SHQueryValueExW(hkey, NULL, NULL, NULL, wTemp, &dwSize))
302  {
303  WCHAR sNum[5];
304  if (ParseFieldW (wTemp, 2, sNum, 5))
305  icon_idx = _wtoi(sNum);
306  else
307  icon_idx = 0; /* sometimes the icon number is missing */
308  ParseFieldW (wTemp, 1, wTemp, MAX_PATH);
309  PathUnquoteSpacesW(wTemp);
310 
311  if (!wcscmp(L"%1", wTemp)) /* icon is in the file */
312  {
313  ILGetDisplayNameExW(psf, pidl, wTemp, 0);
314  icon_idx = 0;
315  }
316 
317  initIcon->SetNormalIcon(wTemp, icon_idx);
318  }
319  else
320  {
321  initIcon->SetNormalIcon(swShell32Name, 0);
322  }
323 
324  if (hkey)
325  RegCloseKey(hkey);
326  }
327 
328  return initIcon->QueryInterface(iid, ppvOut);
329 }
330 
331 /*
332 CFileSysEnum should do an initial FindFirstFile and do a FindNextFile as each file is
333 returned by Next. When the enumerator is created, it can do numerous additional operations
334 including formatting a drive, reconnecting a network share drive, and requesting a disk
335 be inserted in a removable drive.
336 */
337 
338 /***********************************************************************
339 * IShellFolder implementation
340 */
341 
343  public CEnumIDListBase
344 {
345  private:
346  public:
347  CFileSysEnum();
348  ~CFileSysEnum();
350 
352  COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
353  END_COM_MAP()
354 };
355 
357 {
358 }
359 
361 {
362 }
363 
365 {
366  WIN32_FIND_DATAW stffile;
367  HANDLE hFile;
369  BOOL succeeded = TRUE;
370  static const WCHAR stars[] = { '*','.','*',0 };
371  static const WCHAR dot[] = { '.',0 };
372  static const WCHAR dotdot[] = { '.','.',0 };
373 
374  TRACE("(%p)->(path=%s flags=0x%08x)\n", this, debugstr_w(lpszPath), dwFlags);
375 
376  if(!lpszPath || !lpszPath[0]) return FALSE;
377 
378  wcscpy(szPath, lpszPath);
381 
382  hFile = FindFirstFileW(szPath,&stffile);
383  if ( hFile != INVALID_HANDLE_VALUE )
384  {
385  BOOL findFinished = FALSE;
386 
387  do
388  {
389  if ( !(stffile.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
390  || (dwFlags & SHCONTF_INCLUDEHIDDEN) )
391  {
392  LPITEMIDLIST pidl = NULL;
393 
394  if ( (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
395  dwFlags & SHCONTF_FOLDERS &&
396  strcmpW(stffile.cFileName, dot) && strcmpW(stffile.cFileName, dotdot))
397  {
398  pidl = _ILCreateFromFindDataW(&stffile);
399  succeeded = succeeded && AddToEnumList(pidl);
400  }
401  else if (!(stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
402  && dwFlags & SHCONTF_NONFOLDERS)
403  {
404  pidl = _ILCreateFromFindDataW(&stffile);
405  succeeded = succeeded && AddToEnumList(pidl);
406  }
407  }
408  if (succeeded)
409  {
410  if (!FindNextFileW(hFile, &stffile))
411  {
413  findFinished = TRUE;
414  else
415  succeeded = FALSE;
416  }
417  }
418  } while (succeeded && !findFinished);
419  FindClose(hFile);
420  }
421 
422  return succeeded;
423 }
424 
426 {
427  pclsid = (CLSID *)&CLSID_ShellFSFolder;
428  sPathTarget = NULL;
429  pidlRoot = NULL;
431 }
432 
434 {
435  TRACE("-- destroying IShellFolder(%p)\n", this);
436 
437  SHFree(pidlRoot);
439 }
440 
441 
442 static const shvheader GenericSFHeader[] = {
449 };
450 
451 #define GENERICSHELLVIEWCOLUMNS 6
452 
453 /**************************************************************************
454  * SHELL32_CreatePidlFromBindCtx [internal]
455  *
456  * If the caller bound File System Bind Data, assume it is the
457  * find data for the path.
458  * This allows binding of paths that don't exist.
459  */
461 {
463  LPITEMIDLIST pidl = NULL;
464  IUnknown *param = NULL;
465  WIN32_FIND_DATAW wfd;
466  HRESULT r;
467 
468  TRACE("%p %s\n", pbc, debugstr_w(path));
469 
470  if (!pbc)
471  return NULL;
472 
473  /* see if the caller bound File System Bind Data */
474  r = pbc->GetObjectParam((LPOLESTR)STR_FILE_SYS_BIND_DATA, &param);
475  if (FAILED(r))
476  return NULL;
477 
478  r = param->QueryInterface(IID_PPV_ARG(IFileSystemBindData,&fsbd));
479  if (SUCCEEDED(r))
480  {
481  r = fsbd->GetFindData(&wfd);
482  if (SUCCEEDED(r))
483  {
484  lstrcpynW(&wfd.cFileName[0], path, MAX_PATH);
485  pidl = _ILCreateFromFindDataW(&wfd);
486  }
487  fsbd->Release();
488  }
489 
490  return pidl;
491 }
492 
493 void SHELL32_GetCLSIDForDirectory(LPCWSTR pwszDir, CLSID* pclsidFolder)
494 {
495  WCHAR wszCLSIDValue[CHARS_IN_GUID];
496  WCHAR wszDesktopIni[MAX_PATH];
497  StringCchCopyW(wszDesktopIni, MAX_PATH, pwszDir);
498  StringCchCatW(wszDesktopIni, MAX_PATH, L"\\desktop.ini");
499 
500  if (GetPrivateProfileStringW(L".ShellClassInfo",
501  L"CLSID",
502  L"",
503  wszCLSIDValue,
504  CHARS_IN_GUID,
505  wszDesktopIni))
506  {
507  CLSIDFromString (wszCLSIDValue, pclsidFolder);
508  }
509 }
510 
512 {
513  DWORD dwFileAttributes, dwShellAttributes;
514 
515  if (!_ILIsFolder(pidl) && !_ILIsValue(pidl))
516  {
517  ERR("Got wrong type of pidl!\n");
518  *pdwAttributes &= SFGAO_CANLINK;
519  return S_OK;
520  }
521 
523 
524  /* Set common attributes */
525  dwShellAttributes = SFGAO_CANCOPY | SFGAO_CANMOVE | SFGAO_CANLINK | SFGAO_CANRENAME | SFGAO_CANDELETE |
526  SFGAO_HASPROPSHEET | SFGAO_DROPTARGET | SFGAO_FILESYSTEM;
527 
529  dwShellAttributes |= (SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR | SFGAO_STORAGEANCESTOR | SFGAO_STORAGE);
530  else
531  dwShellAttributes |= SFGAO_STREAM;
532 
534  dwShellAttributes |= SFGAO_HIDDEN;
535 
537  dwShellAttributes |= SFGAO_READONLY;
538 
539  if (SFGAO_LINK & *pdwAttributes)
540  {
541  char ext[MAX_PATH];
542 
543  if (_ILGetExtension(pidl, ext, MAX_PATH) && !lstrcmpiA(ext, "lnk"))
544  dwShellAttributes |= SFGAO_LINK;
545  }
546 
547  if (SFGAO_HASSUBFOLDER & *pdwAttributes)
548  {
549  CComPtr<IShellFolder> psf2;
550  if (SUCCEEDED(psf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &psf2))))
551  {
552  CComPtr<IEnumIDList> pEnumIL;
553  if (SUCCEEDED(psf2->EnumObjects(0, SHCONTF_FOLDERS, &pEnumIL)))
554  {
555  if (pEnumIL->Skip(1) == S_OK)
556  dwShellAttributes |= SFGAO_HASSUBFOLDER;
557  }
558  }
559  }
560 
561  *pdwAttributes = dwShellAttributes;
562 
563  TRACE ("-- 0x%08x\n", *pdwAttributes);
564  return S_OK;
565 }
566 
567 /**************************************************************************
568 * CFSFolder::ParseDisplayName {SHELL32}
569 *
570 * Parse a display name.
571 *
572 * PARAMS
573 * hwndOwner [in] Parent window for any message's
574 * pbc [in] optional FileSystemBindData context
575 * lpszDisplayName [in] Unicode displayname.
576 * pchEaten [out] (unicode) characters processed
577 * ppidl [out] complex pidl to item
578 * pdwAttributes [out] items attributes
579 *
580 * NOTES
581 * Every folder tries to parse only its own (the leftmost) pidl and creates a
582 * subfolder to evaluate the remaining parts.
583 * Now we can parse into namespaces implemented by shell extensions
584 *
585 * Behaviour on win98: lpszDisplayName=NULL -> crash
586 * lpszDisplayName="" -> returns mycoputer-pidl
587 *
588 * FIXME
589 * pdwAttributes is not set
590 * pchEaten is not set like in windows
591 */
593  LPBC pbc,
594  LPOLESTR lpszDisplayName,
595  DWORD *pchEaten, PIDLIST_RELATIVE *ppidl,
596  DWORD *pdwAttributes)
597 {
599  LPCWSTR szNext = NULL;
602  LPITEMIDLIST pidlTemp = NULL;
603  DWORD len;
604 
605  TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
606  this, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
607  pchEaten, ppidl, pdwAttributes);
608 
609  if (!ppidl)
610  return E_INVALIDARG;
611 
612  if (!lpszDisplayName)
613  {
614  *ppidl = NULL;
615  return E_INVALIDARG;
616  }
617 
618  *ppidl = NULL;
619 
620  if (pchEaten)
621  *pchEaten = 0; /* strange but like the original */
622 
623  if (*lpszDisplayName)
624  {
625  /* get the next element */
626  szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
627 
628  pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, szElement);
629  if (pidlTemp != NULL)
630  {
631  /* We are creating an id list without ensuring that the items exist.
632  If we have a remaining path, this must be a folder.
633  We have to do it now because it is set as a file by default */
634  if (szNext)
635  {
636  pidlTemp->mkid.abID[0] = PT_FOLDER;
637  }
638  hr = S_OK;
639  }
640  else
641  {
642  /* build the full pathname to the element */
645  len = wcslen(szPath);
647 
648  /* get the pidl */
649  hr = _ILCreateFromPathW(szPath, &pidlTemp);
650  }
651 
652  if (SUCCEEDED(hr))
653  {
654  if (szNext && *szNext)
655  {
656  /* try to analyse the next element */
657  hr = SHELL32_ParseNextElement(this, hwndOwner, pbc,
658  &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
659  }
660  else
661  {
662  /* it's the last element */
663  if (pdwAttributes && *pdwAttributes)
664  hr = SHELL32_GetFSItemAttributes(this, pidlTemp, pdwAttributes);
665  }
666  }
667  }
668 
669  if (SUCCEEDED(hr))
670  *ppidl = pidlTemp;
671  else
672  *ppidl = NULL;
673 
674  TRACE("(%p)->(-- pidl=%p ret=0x%08x)\n", this, ppidl ? *ppidl : 0, hr);
675 
676  return hr;
677 }
678 
679 /**************************************************************************
680 * CFSFolder::EnumObjects
681 * PARAMETERS
682 * HWND hwndOwner, //[in ] Parent Window
683 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
684 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
685 */
687  HWND hwndOwner,
688  DWORD dwFlags,
689  LPENUMIDLIST *ppEnumIDList)
690 {
691  return ShellObjectCreatorInit<CFileSysEnum>(sPathTarget, dwFlags, IID_PPV_ARG(IEnumIDList, ppEnumIDList));
692 }
693 
694 /**************************************************************************
695 * CFSFolder::BindToObject
696 * PARAMETERS
697 * LPCITEMIDLIST pidl, //[in ] relative pidl to open
698 * LPBC pbc, //[in ] optional FileSystemBindData context
699 * REFIID riid, //[in ] Initial Interface
700 * LPVOID* ppvObject //[out] Interface*
701 */
703  PCUIDLIST_RELATIVE pidl,
704  LPBC pbc,
705  REFIID riid,
706  LPVOID * ppvOut)
707 {
708  TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", this, pidl, pbc,
709  shdebugstr_guid(&riid), ppvOut);
710 
711  CComPtr<IShellFolder> pSF;
712  HRESULT hr;
713 
714  if (!pidlRoot || !ppvOut || !pidl || !pidl->mkid.cb)
715  {
716  ERR("CFSFolder::BindToObject: Invalid parameters\n");
717  return E_INVALIDARG;
718  }
719 
720  /* Get the pidl data */
721  FileStruct* pData = &_ILGetDataPointer(pidl)->u.file;
722  FileStructW* pDataW = _ILGetFileStructW(pidl);
723 
724  if (!pDataW)
725  {
726  ERR("CFSFolder::BindToObject: Invalid pidl!\n");
727  return E_INVALIDARG;
728  }
729 
730  *ppvOut = NULL;
731 
732  /* Create the target folder info */
733  PERSIST_FOLDER_TARGET_INFO pfti = {0};
734  pfti.dwAttributes = -1;
735  pfti.csidl = -1;
737 
738  /* Get the CLSID to bind to */
739  CLSID clsidFolder;
740  if (_ILIsFolder(pidl))
741  {
742  clsidFolder = CLSID_ShellFSFolder;
743 
744  if ((pData->uFileAttribs & (FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_READONLY)) != 0)
746  }
747  else
748  {
749  hr = GetCLSIDForFileType(pidl, L"CLSID", &clsidFolder);
750  if (hr == S_FALSE)
752  if (hr != S_OK)
753  return hr;
754  }
755 
756  hr = SHELL32_BindToSF(pidlRoot, &pfti, pidl, &clsidFolder, riid, ppvOut);
757  if (FAILED_UNEXPECTEDLY(hr))
758  return hr;
759 
760  TRACE ("-- returning (%p) %08x\n", *ppvOut, hr);
761 
762  return S_OK;
763 
764 }
765 
766 /**************************************************************************
767 * CFSFolder::BindToStorage
768 * PARAMETERS
769 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
770 * LPBC pbc, //[in ] reserved
771 * REFIID riid, //[in ] Initial storage interface
772 * LPVOID* ppvObject //[out] Interface* returned
773 */
775  PCUIDLIST_RELATIVE pidl,
776  LPBC pbcReserved,
777  REFIID riid,
778  LPVOID *ppvOut)
779 {
780  FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", this, pidl, pbcReserved,
781  shdebugstr_guid (&riid), ppvOut);
782 
783  *ppvOut = NULL;
784  return E_NOTIMPL;
785 }
786 
787 /**************************************************************************
788 * CFSFolder::CompareIDs
789 */
790 
792  PCUIDLIST_RELATIVE pidl1,
793  PCUIDLIST_RELATIVE pidl2)
794 {
795  LPPIDLDATA pData1 = _ILGetDataPointer(pidl1);
796  LPPIDLDATA pData2 = _ILGetDataPointer(pidl2);
797  FileStructW* pDataW1 = _ILGetFileStructW(pidl1);
798  FileStructW* pDataW2 = _ILGetFileStructW(pidl2);
799  BOOL bIsFolder1 = _ILIsFolder(pidl1);
800  BOOL bIsFolder2 = _ILIsFolder(pidl2);
801  LPWSTR pExtension1, pExtension2;
802 
803  if (!pDataW1 || !pDataW2 || LOWORD(lParam) >= GENERICSHELLVIEWCOLUMNS)
804  return E_INVALIDARG;
805 
806  /* When sorting between a File and a Folder, the Folder gets sorted first */
807  if (bIsFolder1 != bIsFolder2)
808  {
809  return MAKE_COMPARE_HRESULT(bIsFolder1 ? -1 : 1);
810  }
811 
812  int result;
813  switch (LOWORD(lParam))
814  {
815  case 0: /* Name */
816  result = wcsicmp(pDataW1->wszName, pDataW2->wszName);
817  break;
818  case 1: /* Comments */
819  result = 0;
820  break;
821  case 2: /* Type */
822  pExtension1 = PathFindExtensionW(pDataW1->wszName);
823  pExtension2 = PathFindExtensionW(pDataW2->wszName);
824  result = wcsicmp(pExtension1, pExtension2);
825  break;
826  case 3: /* Size */
827  result = pData1->u.file.dwFileSize - pData2->u.file.dwFileSize;
828  break;
829  case 4: /* Modified */
830  result = pData1->u.file.uFileDate - pData2->u.file.uFileDate;
831  if (result == 0)
832  result = pData1->u.file.uFileTime - pData2->u.file.uFileTime;
833  break;
834  case 5: /* Attributes */
835  return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
836  }
837 
838  if (result == 0)
839  return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
840 
842 }
843 
844 /**************************************************************************
845 * CFSFolder::CreateViewObject
846 */
848  REFIID riid, LPVOID * ppvOut)
849 {
850  CComPtr<IShellView> pShellView;
852 
853  TRACE ("(%p)->(hwnd=%p,%s,%p)\n", this, hwndOwner, shdebugstr_guid (&riid),
854  ppvOut);
855 
856  if (ppvOut)
857  {
858  *ppvOut = NULL;
859 
860  if (IsEqualIID (riid, IID_IDropTarget))
862  else if (IsEqualIID (riid, IID_IContextMenu))
863  {
864  HKEY hKeys[16];
865  UINT cKeys = 0;
866  AddClassKeyToArray(L"Directory\\Background", hKeys, &cKeys);
867 
868  DEFCONTEXTMENU dcm;
869  dcm.hwnd = hwndOwner;
870  dcm.pcmcb = this;
871  dcm.pidlFolder = pidlRoot;
872  dcm.psf = this;
873  dcm.cidl = 0;
874  dcm.apidl = NULL;
875  dcm.cKeys = cKeys;
876  dcm.aKeys = hKeys;
878  hr = SHCreateDefaultContextMenu (&dcm, riid, ppvOut);
879  }
880  else if (IsEqualIID (riid, IID_IShellView))
881  {
882  SFV_CREATE sfvparams = {sizeof(SFV_CREATE), this, NULL, this};
883  hr = SHCreateShellFolderView(&sfvparams, (IShellView**)ppvOut);
884  }
885  }
886  TRACE("-- (%p)->(interface=%p)\n", this, ppvOut);
887  return hr;
888 }
889 
890 /**************************************************************************
891 * CFSFolder::GetAttributesOf
892 *
893 * PARAMETERS
894 * UINT cidl, //[in ] num elements in pidl array
895 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
896 * ULONG* rgfInOut) //[out] result array
897 *
898 */
900  PCUITEMID_CHILD_ARRAY apidl, DWORD * rgfInOut)
901 {
902  HRESULT hr = S_OK;
903 
904  if (!rgfInOut)
905  return E_INVALIDARG;
906  if (cidl && !apidl)
907  return E_INVALIDARG;
908 
909  if (*rgfInOut == 0)
910  *rgfInOut = ~0;
911 
912  if(cidl == 0)
913  {
915 
916  if (_ILIsFolder(rpidl) || _ILIsValue(rpidl))
917  {
918  SHELL32_GetFSItemAttributes(this, rpidl, rgfInOut);
919  }
920  else if (_ILIsDrive(rpidl))
921  {
922  IShellFolder *psfParent = NULL;
924  if(SUCCEEDED(hr))
925  {
926  hr = psfParent->GetAttributesOf(1, &rpidl, (SFGAOF*)rgfInOut);
927  psfParent->Release();
928  }
929  }
930  else
931  {
932  ERR("Got and unknown pidl!\n");
933  }
934  }
935  else
936  {
937  while (cidl > 0 && *apidl)
938  {
939  pdump(*apidl);
940  if(_ILIsFolder(*apidl) || _ILIsValue(*apidl))
941  SHELL32_GetFSItemAttributes(this, *apidl, rgfInOut);
942  else
943  ERR("Got an unknown type of pidl!!!\n");
944  apidl++;
945  cidl--;
946  }
947  }
948  /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
949  *rgfInOut &= ~SFGAO_VALIDATE;
950 
951  TRACE("-- result=0x%08x\n", *rgfInOut);
952 
953  return hr;
954 }
955 
956 /**************************************************************************
957 * CFSFolder::GetUIObjectOf
958 *
959 * PARAMETERS
960 * HWND hwndOwner, //[in ] Parent window for any output
961 * UINT cidl, //[in ] array size
962 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
963 * REFIID riid, //[in ] Requested Interface
964 * UINT* prgfInOut, //[ ] reserved
965 * LPVOID* ppvObject) //[out] Resulting Interface
966 *
967 * NOTES
968 * This function gets asked to return "view objects" for one or more (multiple
969 * select) items:
970 * The viewobject typically is an COM object with one of the following
971 * interfaces:
972 * IExtractIcon,IDataObject,IContextMenu
973 * In order to support icon positions in the default Listview your DataObject
974 * must implement the SetData method (in addition to GetData :) - the shell
975 * passes a barely documented "Icon positions" structure to SetData when the
976 * drag starts, and GetData's it if the drop is in another explorer window that
977 * needs the positions.
978 */
980  UINT cidl, PCUITEMID_CHILD_ARRAY apidl,
981  REFIID riid, UINT * prgfInOut,
982  LPVOID * ppvOut)
983 {
984  LPVOID pObj = NULL;
986 
987  TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
988  this, hwndOwner, cidl, apidl, shdebugstr_guid (&riid), prgfInOut, ppvOut);
989 
990  if (ppvOut)
991  {
992  *ppvOut = NULL;
993 
994  if (cidl == 1 && _ILIsValue(apidl[0]))
995  {
996  hr = _CreateExtensionUIObject(apidl[0], riid, ppvOut);
997  if(hr != S_FALSE)
998  return hr;
999  }
1000 
1001  if (IsEqualIID(riid, IID_IContextMenu) && (cidl >= 1))
1002  {
1003  HKEY hKeys[16];
1004  UINT cKeys = 0;
1005  AddFSClassKeysToArray(apidl[0], hKeys, &cKeys);
1006 
1007  DEFCONTEXTMENU dcm;
1008  dcm.hwnd = hwndOwner;
1009  dcm.pcmcb = this;
1010  dcm.pidlFolder = pidlRoot;
1011  dcm.psf = this;
1012  dcm.cidl = cidl;
1013  dcm.apidl = apidl;
1014  dcm.cKeys = cKeys;
1015  dcm.aKeys = hKeys;
1016  dcm.punkAssociationInfo = NULL;
1017  hr = SHCreateDefaultContextMenu (&dcm, riid, &pObj);
1018  }
1019  else if (IsEqualIID (riid, IID_IDataObject))
1020  {
1021  if (cidl >= 1)
1022  {
1023  hr = IDataObject_Constructor (hwndOwner, pidlRoot, apidl, cidl, (IDataObject **)&pObj);
1024  }
1025  else
1026  {
1027  hr = E_INVALIDARG;
1028  }
1029  }
1030  else if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
1031  {
1032  if (_ILIsValue(apidl[0]))
1033  hr = _GetIconHandler(apidl[0], riid, (LPVOID*)&pObj);
1034  if (hr != S_OK)
1035  hr = CFSExtractIcon_CreateInstance(this, apidl[0], riid, &pObj);
1036  }
1037  else if (IsEqualIID (riid, IID_IDropTarget))
1038  {
1039  /* only interested in attempting to bind to shell folders, not files (except exe), so if we fail, rebind to root */
1040  if (cidl != 1 || FAILED(hr = this->_GetDropTarget(apidl[0], (LPVOID*) &pObj)))
1041  {
1043  }
1044  }
1045  else
1046  hr = E_NOINTERFACE;
1047 
1048  if (SUCCEEDED(hr) && !pObj)
1049  hr = E_OUTOFMEMORY;
1050 
1051  *ppvOut = pObj;
1052  }
1053  TRACE("(%p)->hr=0x%08x\n", this, hr);
1054  return hr;
1055 }
1056 
1057 static const WCHAR AdvancedW[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
1058 static const WCHAR HideFileExtW[] = L"HideFileExt";
1059 static const WCHAR NeverShowExtW[] = L"NeverShowExt";
1060 
1061 /******************************************************************************
1062  * SHELL_FS_HideExtension [Internal]
1063  *
1064  * Query the registry if the filename extension of a given path should be
1065  * hidden.
1066  *
1067  * PARAMS
1068  * szPath [I] Relative or absolute path of a file
1069  *
1070  * RETURNS
1071  * TRUE, if the filename's extension should be hidden
1072  * FALSE, otherwise.
1073  */
1075 {
1076  HKEY hKey;
1077  DWORD dwData;
1078  DWORD dwDataSize = sizeof (DWORD);
1079  BOOL doHide = FALSE; /* The default value is FALSE (win98 at least) */
1080 
1081  if (!RegCreateKeyExW(HKEY_CURRENT_USER, AdvancedW, 0, 0, 0, KEY_ALL_ACCESS, 0, &hKey, 0)) {
1082  if (!RegQueryValueExW(hKey, HideFileExtW, 0, 0, (LPBYTE) &dwData, &dwDataSize))
1083  doHide = dwData;
1084  RegCloseKey (hKey);
1085  }
1086 
1087  if (!doHide) {
1089 
1090  if (*ext != '\0') {
1092  LONG classlen = sizeof(classname);
1093 
1094  if (!RegQueryValueW(HKEY_CLASSES_ROOT, ext, classname, &classlen))
1095  if (!RegOpenKeyW(HKEY_CLASSES_ROOT, classname, &hKey)) {
1096  if (!RegQueryValueExW(hKey, NeverShowExtW, 0, NULL, NULL, NULL))
1097  doHide = TRUE;
1098  RegCloseKey(hKey);
1099  }
1100  }
1101  }
1102  return doHide;
1103 }
1104 
1106 {
1107  /*FIXME: MSDN also mentions SHGDN_FOREDITING which is not yet handled. */
1108  if (!(dwFlags & SHGDN_FORPARSING) &&
1109  ((dwFlags & SHGDN_INFOLDER) || (dwFlags == SHGDN_NORMAL))) {
1110  if (SHELL_FS_HideExtension(szPath) && szPath[0] != '.')
1112  }
1113 }
1114 
1115 /**************************************************************************
1116 * CFSFolder::GetDisplayNameOf
1117 * Retrieves the display name for the specified file object or subfolder
1118 *
1119 * PARAMETERS
1120 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
1121 * DWORD dwFlags, //[in ] SHGNO formatting flags
1122 * LPSTRRET lpName) //[out] Returned display name
1123 *
1124 * FIXME
1125 * if the name is in the pidl the ret value should be a STRRET_OFFSET
1126 */
1127 
1129  DWORD dwFlags, LPSTRRET strRet)
1130 {
1131  if (!strRet)
1132  return E_INVALIDARG;
1133 
1134  /* If it is a complex pidl, let the child handle it */
1135  if (!_ILIsPidlSimple (pidl)) /* complex pidl */
1136  {
1137  return SHELL32_GetDisplayNameOfChild(this, pidl, dwFlags, strRet);
1138  }
1139  else if (pidl && !pidl->mkid.cb) /* empty pidl */
1140  {
1141  /* If it is an empty pidl return only the path of the folder */
1144  sPathTarget)
1145  {
1146  return SHSetStrRet(strRet, sPathTarget);
1147  }
1148  return E_INVALIDARG;
1149  }
1150 
1151  int len = 0;
1152  LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((MAX_PATH + 1) * sizeof(WCHAR));
1153  if (!pszPath)
1154  return E_OUTOFMEMORY;
1155 
1158  sPathTarget)
1159  {
1160  lstrcpynW(pszPath, sPathTarget, MAX_PATH);
1161  PathAddBackslashW(pszPath);
1162  len = wcslen(pszPath);
1163  }
1164  _ILSimpleGetTextW(pidl, pszPath + len, MAX_PATH + 1 - len);
1165  if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
1166 
1167  strRet->uType = STRRET_WSTR;
1168  strRet->pOleStr = pszPath;
1169 
1170  TRACE ("-- (%p)->(%s)\n", this, strRet->uType == STRRET_CSTR ? strRet->cStr : debugstr_w(strRet->pOleStr));
1171  return S_OK;
1172 }
1173 
1174 /**************************************************************************
1175 * CFSFolder::SetNameOf
1176 * Changes the name of a file object or subfolder, possibly changing its item
1177 * identifier in the process.
1178 *
1179 * PARAMETERS
1180 * HWND hwndOwner, //[in ] Owner window for output
1181 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
1182 * LPCOLESTR lpszName, //[in ] the items new display name
1183 * DWORD dwFlags, //[in ] SHGNO formatting flags
1184 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
1185 */
1187  HWND hwndOwner,
1188  PCUITEMID_CHILD pidl,
1189  LPCOLESTR lpName,
1190  DWORD dwFlags,
1191  PITEMID_CHILD *pPidlOut)
1192 {
1193  WCHAR szSrc[MAX_PATH + 1], szDest[MAX_PATH + 1];
1194  BOOL bIsFolder = _ILIsFolder (ILFindLastID (pidl));
1195 
1196  TRACE ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", this, hwndOwner, pidl,
1197  debugstr_w (lpName), dwFlags, pPidlOut);
1198 
1199  FileStructW* pDataW = _ILGetFileStructW(pidl);
1200  if (!pDataW)
1201  {
1202  ERR("Got garbage pidl\n");
1203  return E_INVALIDARG;
1204  }
1205 
1206  /* build source path */
1207  PathCombineW(szSrc, sPathTarget, pDataW->wszName);
1208 
1209  /* build destination path */
1211  PathCombineW(szDest, sPathTarget, lpName);
1212  else
1213  lstrcpynW(szDest, lpName, MAX_PATH);
1214 
1215  if(!(dwFlags & SHGDN_FORPARSING) && SHELL_FS_HideExtension(szSrc)) {
1216  WCHAR *ext = PathFindExtensionW(szSrc);
1217  if(*ext != '\0') {
1218  INT len = wcslen(szDest);
1219  lstrcpynW(szDest + len, ext, MAX_PATH - len);
1220  }
1221  }
1222 
1223  TRACE ("src=%s dest=%s\n", debugstr_w(szSrc), debugstr_w(szDest));
1224  if (!wcscmp(szSrc, szDest))
1225  {
1226  /* src and destination is the same */
1227  HRESULT hr = S_OK;
1228  if (pPidlOut)
1229  hr = _ILCreateFromPathW(szDest, pPidlOut);
1230 
1231  return hr;
1232  }
1233 
1234  if (MoveFileW (szSrc, szDest))
1235  {
1236  HRESULT hr = S_OK;
1237 
1238  if (pPidlOut)
1239  hr = _ILCreateFromPathW(szDest, pPidlOut);
1240 
1242  SHCNF_PATHW, szSrc, szDest);
1243 
1244  return hr;
1245  }
1246 
1247  return E_FAIL;
1248 }
1249 
1251 {
1252  FIXME ("(%p)\n", this);
1253  return E_NOTIMPL;
1254 }
1255 
1257 {
1258  FIXME ("(%p)\n", this);
1259  return E_NOTIMPL;
1260 }
1261 
1263  ULONG * pSort, ULONG * pDisplay)
1264 {
1265  TRACE ("(%p)\n", this);
1266 
1267  if (pSort)
1268  *pSort = 0;
1269  if (pDisplay)
1270  *pDisplay = 0;
1271 
1272  return S_OK;
1273 }
1274 
1276  DWORD * pcsFlags)
1277 {
1278  TRACE ("(%p)\n", this);
1279 
1280  if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS)
1281  return E_INVALIDARG;
1282 
1283  *pcsFlags = GenericSFHeader[iColumn].pcsFlags;
1284 
1285  return S_OK;
1286 }
1287 
1289  const SHCOLUMNID * pscid, VARIANT * pv)
1290 {
1291  FIXME ("(%p)\n", this);
1292 
1293  return E_NOTIMPL;
1294 }
1295 
1297  UINT iColumn, SHELLDETAILS * psd)
1298 {
1299  HRESULT hr = E_FAIL;
1300 
1301  TRACE ("(%p)->(%p %i %p)\n", this, pidl, iColumn, psd);
1302 
1303  if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS)
1304  return E_INVALIDARG;
1305 
1306  if (!pidl)
1307  {
1308  /* the header titles */
1309  psd->fmt = GenericSFHeader[iColumn].fmt;
1310  psd->cxChar = GenericSFHeader[iColumn].cxChar;
1311  return SHSetStrRet(&psd->str, GenericSFHeader[iColumn].colnameid);
1312  }
1313  else
1314  {
1315  hr = S_OK;
1316  psd->str.uType = STRRET_CSTR;
1317  /* the data from the pidl */
1318  switch (iColumn)
1319  {
1320  case 0: /* name */
1321  hr = GetDisplayNameOf (pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
1322  break;
1323  case 1: /* FIXME: comments */
1324  psd->str.cStr[0] = 0;
1325  break;
1326  case 2: /* type */
1327  _ILGetFileType(pidl, psd->str.cStr, MAX_PATH);
1328  break;
1329  case 3: /* size */
1330  _ILGetFileSize(pidl, psd->str.cStr, MAX_PATH);
1331  break;
1332  case 4: /* date */
1333  _ILGetFileDate(pidl, psd->str.cStr, MAX_PATH);
1334  break;
1335  case 5: /* attributes */
1336  _ILGetFileAttributes(pidl, psd->str.cStr, MAX_PATH);
1337  break;
1338  }
1339  }
1340 
1341  return hr;
1342 }
1343 
1345  SHCOLUMNID * pscid)
1346 {
1347  FIXME ("(%p)\n", this);
1348  return E_NOTIMPL;
1349 }
1350 
1351 /************************************************************************
1352  * CFSFolder::GetClassID
1353  */
1355 {
1356  TRACE ("(%p)\n", this);
1357 
1358  if (!lpClassId)
1359  return E_POINTER;
1360 
1361  *lpClassId = *pclsid;
1362 
1363  return S_OK;
1364 }
1365 
1366 /************************************************************************
1367  * CFSFolder::Initialize
1368  *
1369  * NOTES
1370  * sPathTarget is not set. Don't know how to handle in a non rooted environment.
1371  */
1373 {
1374  WCHAR wszTemp[MAX_PATH];
1375 
1376  TRACE ("(%p)->(%p)\n", this, pidl);
1377 
1378  SHFree (pidlRoot); /* free the old pidl */
1379  pidlRoot = ILClone (pidl); /* set my pidl */
1380 
1381  SHFree (sPathTarget);
1382  sPathTarget = NULL;
1383 
1384  /* set my path */
1385  if (SHGetPathFromIDListW (pidl, wszTemp))
1386  {
1387  int len = wcslen(wszTemp);
1388  sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
1389  if (!sPathTarget)
1390  return E_OUTOFMEMORY;
1391  memcpy(sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR));
1392  }
1393 
1394  TRACE ("--(%p)->(%s)\n", this, debugstr_w(sPathTarget));
1395  return S_OK;
1396 }
1397 
1398 /**************************************************************************
1399  * CFSFolder::GetCurFolder
1400  */
1402 {
1403  TRACE ("(%p)->(%p)\n", this, pidl);
1404 
1405  if (!pidl)
1406  return E_POINTER;
1407 
1408  *pidl = ILClone(pidlRoot);
1409  return S_OK;
1410 }
1411 
1412 /**************************************************************************
1413  * CFSFolder::InitializeEx
1414  *
1415  * FIXME: error handling
1416  */
1418  const PERSIST_FOLDER_TARGET_INFO * ppfti)
1419 {
1420  WCHAR wszTemp[MAX_PATH];
1421 
1422  TRACE("(%p)->(%p,%p,%p)\n", this, pbc, pidlRootx, ppfti);
1423  if (ppfti)
1424  TRACE("--%p %s %s 0x%08x 0x%08x\n",
1426  debugstr_w (ppfti->szNetworkProvider), ppfti->dwAttributes,
1427  ppfti->csidl);
1428 
1429  pdump (pidlRootx);
1430  if (ppfti && ppfti->pidlTargetFolder)
1431  pdump(ppfti->pidlTargetFolder);
1432 
1433  if (pidlRoot)
1434  __SHFreeAndNil(&pidlRoot); /* free the old */
1435  if (sPathTarget)
1437 
1438  /*
1439  * Root path and pidl
1440  */
1441  pidlRoot = ILClone(pidlRootx);
1442 
1443  /*
1444  * the target folder is spezified in csidl OR pidlTargetFolder OR
1445  * szTargetParsingName
1446  */
1447  if (ppfti)
1448  {
1449  if (ppfti->csidl != -1)
1450  {
1451  if (SHGetSpecialFolderPathW(0, wszTemp, ppfti->csidl,
1452  ppfti->csidl & CSIDL_FLAG_CREATE)) {
1453  int len = wcslen(wszTemp);
1454  sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
1455  if (!sPathTarget)
1456  return E_OUTOFMEMORY;
1457  memcpy(sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR));
1458  }
1459  }
1460  else if (ppfti->szTargetParsingName[0])
1461  {
1462  int len = wcslen(ppfti->szTargetParsingName);
1463  sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
1464  if (!sPathTarget)
1465  return E_OUTOFMEMORY;
1467  (len + 1) * sizeof(WCHAR));
1468  }
1469  else if (ppfti->pidlTargetFolder)
1470  {
1471  if (SHGetPathFromIDListW(ppfti->pidlTargetFolder, wszTemp))
1472  {
1473  int len = wcslen(wszTemp);
1474  sPathTarget = (WCHAR *)SHAlloc((len + 1) * sizeof(WCHAR));
1475  if (!sPathTarget)
1476  return E_OUTOFMEMORY;
1477  memcpy(sPathTarget, wszTemp, (len + 1) * sizeof(WCHAR));
1478  }
1479  }
1480  }
1481 
1482  TRACE("--(%p)->(target=%s)\n", this, debugstr_w(sPathTarget));
1483  pdump(pidlRoot);
1484  return (sPathTarget) ? S_OK : E_FAIL;
1485 }
1486 
1488 {
1489  FIXME("(%p)->(%p)\n", this, ppfti);
1490  ZeroMemory(ppfti, sizeof (*ppfti));
1491  return E_NOTIMPL;
1492 }
1493 
1495 {
1496  static const WCHAR formatW[] = {'S','h','e','l','l','E','x','\\',
1497  '{','%','0','8','x','-','%','0','4','x','-','%','0','4','x','-',
1498  '%','0','2','x','%','0','2','x','-','%','0','2','x','%','0','2','x',
1499  '%','0','2','x','%','0','2','x','%','0','2','x','%','0','2','x','}',0};
1500  WCHAR buf[MAX_PATH];
1501 
1502  sprintfW(buf, formatW, riid.Data1, riid.Data2, riid.Data3,
1503  riid.Data4[0], riid.Data4[1], riid.Data4[2], riid.Data4[3],
1504  riid.Data4[4], riid.Data4[5], riid.Data4[6], riid.Data4[7]);
1505 
1506  CLSID clsid;
1507  HRESULT hr;
1508 
1509  hr = GetCLSIDForFileType(pidl, buf, &clsid);
1510  if (hr != S_OK)
1511  return hr;
1512 
1513  hr = _CreateShellExtInstance(&clsid, pidl, riid, ppvOut);
1514  if (FAILED_UNEXPECTEDLY(hr))
1515  return hr;
1516 
1517  return S_OK;
1518 }
1519 
1521 {
1522  HRESULT hr;
1523 
1524  TRACE("CFSFolder::_GetDropTarget entered\n");
1525 
1526  if (_ILIsFolder (pidl))
1527  {
1528  CComPtr<IShellFolder> psfChild;
1529  hr = this->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder, &psfChild));
1530  if (FAILED_UNEXPECTEDLY(hr))
1531  return hr;
1532 
1533  return psfChild->CreateViewObject(NULL, IID_IDropTarget, ppvOut);
1534  }
1535 
1536  CLSID clsid;
1537  hr = GetCLSIDForFileType(pidl, L"shellex\\DropHandler", &clsid);
1538  if (hr != S_OK)
1539  return hr;
1540 
1541  hr = _CreateShellExtInstance(&clsid, pidl, IID_IDropTarget, ppvOut);
1542  if (FAILED_UNEXPECTEDLY(hr))
1543  return S_FALSE;
1544 
1545  return S_OK;
1546 }
1547 
1549 {
1550  CLSID clsid;
1551  HRESULT hr;
1552 
1553  hr = GetCLSIDForFileType(pidl, L"shellex\\IconHandler", &clsid);
1554  if (hr != S_OK)
1555  return hr;
1556 
1557  hr = _CreateShellExtInstance(&clsid, pidl, riid, ppvOut);
1558  if (FAILED_UNEXPECTEDLY(hr))
1559  return S_FALSE;
1560 
1561  return S_OK;
1562 }
1563 
1565 {
1566  HRESULT hr;
1567  WCHAR wszPath[MAX_PATH];
1568 
1569  FileStructW* pDataW = _ILGetFileStructW(pidl);
1570  if (!pDataW)
1571  {
1572  ERR("Got garbage pidl\n");
1573  return E_INVALIDARG;
1574  }
1575 
1576  PathCombineW(wszPath, sPathTarget, pDataW->wszName);
1577 
1578  CComPtr<IPersistFile> pp;
1580  if (FAILED_UNEXPECTEDLY(hr))
1581  return hr;
1582 
1583  pp->Load(wszPath, 0);
1584 
1585  hr = pp->QueryInterface(riid, ppvOut);
1586  if (hr != S_OK)
1587  {
1588  ERR("Failed to query for interface IID_IShellExtInit hr %x pclsid %s\n", hr, wine_dbgstr_guid(pclsid));
1589  return hr;
1590  }
1591  return hr;
1592 }
1593 
1595 {
1596  if (uMsg != DFM_MERGECONTEXTMENU && uMsg != DFM_INVOKECOMMAND)
1597  return S_OK;
1598 
1599  /* no data object means no selection */
1600  if (!pdtobj)
1601  {
1602  if (uMsg == DFM_INVOKECOMMAND && wParam == 0)
1603  {
1605  LPITEMIDLIST pidlParent = ILClone(pidlRoot);
1606  ILRemoveLastID(pidlParent);
1607  HRESULT hr = SH_ShowPropertiesDialog(sPathTarget, pidlParent, &pidlChild);
1608  if (FAILED(hr))
1609  ERR("SH_ShowPropertiesDialog failed\n");
1610  ILFree(pidlChild);
1611  ILFree(pidlParent);
1612  }
1613  else if (uMsg == DFM_MERGECONTEXTMENU)
1614  {
1615  QCMINFO *pqcminfo = (QCMINFO *)lParam;
1616  HMENU hpopup = CreatePopupMenu();
1618  Shell_MergeMenus(pqcminfo->hmenu, hpopup, pqcminfo->indexMenu++, pqcminfo->idCmdFirst, pqcminfo->idCmdLast, MM_ADDSEPARATOR);
1619  DestroyMenu(hpopup);
1620  }
1621 
1622  return S_OK;
1623  }
1624 
1625  if (uMsg != DFM_INVOKECOMMAND || wParam != DFM_CMD_PROPERTIES)
1626  return S_OK;
1627 
1628  return Shell_DefaultContextMenuCallBack(this, pdtobj);
1629 }
1630 
1632 {
1633  // create stream from file
1634  HRESULT hr;
1635  CComPtr<IStream> pStream;
1637  FALSE, NULL, &pStream);
1638  if (FAILED(hr))
1639  return NULL;
1640 
1641  // load the picture
1642  HBITMAP hbm = NULL;
1643  CComPtr<IPicture> pPicture;
1644  OleLoadPicture(pStream, 0, FALSE, IID_IPicture, (LPVOID *)&pPicture);
1645 
1646  // get the bitmap handle
1647  if (pPicture)
1648  {
1649  pPicture->get_Handle((OLE_HANDLE *)&hbm);
1650 
1651  // copy the bitmap handle
1653  }
1654 
1655  return hbm;
1656 }
1657 
1659 {
1660  if (data == NULL)
1661  {
1662  return E_POINTER;
1663  }
1664  if (data->cbSize != sizeof(*data))
1665  {
1666  // NOTE: You have to set the cbData member before SFVM_GET_CUSTOMVIEWINFO call.
1667  return E_INVALIDARG;
1668  }
1669 
1670  data->hbmBack = NULL;
1671  data->clrText = CLR_INVALID;
1672  data->clrTextBack = CLR_INVALID;
1673 
1675 
1676  // does the folder exists?
1678  {
1679  return E_INVALIDARG;
1680  }
1681 
1682  // don't use custom view in network path for security
1684  {
1685  return E_ACCESSDENIED;
1686  }
1687 
1688  // build the ini file path
1690  PathAppend(szIniFile, L"desktop.ini");
1691 
1692  static LPCWSTR TheGUID = L"{BE098140-A513-11D0-A3A4-00C04FD706EC}";
1693  static LPCWSTR Space = L" \t\n\r\f\v";
1694 
1695  // get info from ini file
1696  WCHAR szImage[MAX_PATH], szText[64];
1697 
1698  // load the image
1699  szImage[0] = UNICODE_NULL;
1700  GetPrivateProfileStringW(TheGUID, L"IconArea_Image", L"", szImage, _countof(szImage), szIniFile);
1701  if (szImage[0])
1702  {
1703  StrTrimW(szImage, Space);
1704  if (PathIsRelativeW(szImage))
1705  {
1706  PathAppendW(szPath, szImage);
1707  StringCchCopyW(szImage, _countof(szImage), szPath);
1708  }
1709  data->hbmBack = DoLoadPicture(szImage);
1710  }
1711 
1712  // load the text color
1713  szText[0] = UNICODE_NULL;
1714  GetPrivateProfileStringW(TheGUID, L"IconArea_Text", L"", szText, _countof(szText), szIniFile);
1715  if (szText[0])
1716  {
1717  StrTrimW(szText, Space);
1718 
1719  LPWSTR pchEnd = NULL;
1720  COLORREF cr = (wcstol(szText, &pchEnd, 0) & 0xFFFFFF);
1721 
1722  if (pchEnd && !*pchEnd)
1723  data->clrText = cr;
1724  }
1725 
1726  // load the text background color
1727  szText[0] = UNICODE_NULL;
1728  GetPrivateProfileStringW(TheGUID, L"IconArea_TextBackground", L"", szText, _countof(szText), szIniFile);
1729  if (szText[0])
1730  {
1731  StrTrimW(szText, Space);
1732 
1733  LPWSTR pchEnd = NULL;
1734  COLORREF cr = (wcstol(szText, &pchEnd, 0) & 0xFFFFFF);
1735 
1736  if (pchEnd && !*pchEnd)
1737  data->clrTextBack = cr;
1738  }
1739 
1740  if (data->hbmBack != NULL || data->clrText != CLR_INVALID || data->clrTextBack != CLR_INVALID)
1741  return S_OK;
1742 
1743  return E_FAIL;
1744 }
1745 
1747 {
1748  HRESULT hr = E_NOTIMPL;
1749  switch (uMsg)
1750  {
1753  break;
1754  }
1755  return hr;
1756 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1975
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
#define IDS_SHV_COLUMN_COMMENTS
Definition: shresdef.h:61
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1702
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
HRESULT _CreateShellExtInstance(const CLSID *pclsid, LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:1564
UINT idCmdLast
Definition: shlobj.h:1309
#define E_ACCESSDENIED
Definition: winerror.h:2849
#define MFT_STRING
Definition: winuser.h:741
INT WINAPI GetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, LPCWSTR def_val, LPWSTR buffer, UINT len, LPCWSTR filename)
Definition: profile.c:1142
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1558
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2162
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
Definition: fci.c:115
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:857
HRESULT CFSDropTarget_CreateInstance(LPWSTR sPathTarget, REFIID riid, LPVOID *ppvOut)
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2581
HRESULT hr
Definition: shlfolder.c:183
virtual HRESULT WINAPI GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd)
Definition: CFSFolder.cpp:1296
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
const HKEY * aKeys
Definition: shlobj.h:2348
static HRESULT getDefaultIconLocation(LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT uFlags)
Definition: CFSFolder.cpp:134
interface IBindCtx * LPBC
Definition: objfwd.h:18
#define GET_SHGDN_RELATION(dwFlags)
Definition: precomp.h:53
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define KEY_READ
Definition: nt_native.h:1023
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
REFIID riid
Definition: precomp.h:44
virtual HRESULT WINAPI EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
Definition: CFSFolder.cpp:686
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL AddToEnumList(LPITEMIDLIST pidl)
HRESULT _GetDropTarget(LPCITEMIDLIST pidl, LPVOID *ppvOut)
Definition: CFSFolder.cpp:1520
#define _countof(array)
Definition: fontsub.cpp:30
#define HKEY_CURRENT_USER
Definition: winreg.h:11
WCHAR wszName[1]
Definition: shlfolder.c:1555
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:294
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
HRESULT WINAPI Shell_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdtobj)
Definition: shlfolder.cpp:450
HRESULT WINAPI SHCreateDefaultContextMenu(const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv)
#define WARN(fmt,...)
Definition: debug.h:111
#define CHARS_IN_GUID
void AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:267
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1737
#define LVCFMT_RIGHT
Definition: commctrl.h:2571
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
IContextMenuCB * pcmcb
Definition: shlobj.h:2341
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define CLR_INVALID
Definition: wingdi.h:882
virtual HRESULT WINAPI GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv)
Definition: CFSFolder.cpp:1288
LPWSTR pOleStr
Definition: shtypes.idl:96
HMENU hmenu
Definition: shlobj.h:1306
const char * shdebugstr_guid(const struct _GUID *id)
Definition: debughlp.cpp:414
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
static const WCHAR NeverShowExtW[]
Definition: CFSFolder.cpp:1059
#define LVCFMT_LEFT
Definition: commctrl.h:2570
static HANDLE ULONG_PTR dwData
Definition: file.c:35
virtual HRESULT WINAPI Initialize(LPCITEMIDLIST pidl)
Definition: CFSFolder.cpp:1372
const char * wine_dbgstr_guid(const GUID *guid)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
#define RRF_RT_REG_SZ
Definition: driver.c:575
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1105
const GUID IID_IDataObject
HRESULT WINAPI Initialize(LPWSTR sPathTarget, DWORD dwFlags)
Definition: CFSFolder.cpp:364
virtual HRESULT WINAPI MapColumnToSCID(UINT column, SHCOLUMNID *pscid)
Definition: CFSFolder.cpp:1344
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:380
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
static BOOL getShellClassInfo(LPCWSTR Entry, LPWSTR pszValue, DWORD cchValueLen, LPCWSTR IniFile)
Definition: CFSFolder.cpp:159
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
WCHAR classname[128]
Definition: startup.c:15
#define IDS_PROPERTIES
Definition: resource.h:101
UINT uFlags
Definition: api.c:60
#define PathIsNetworkPath
Definition: shlwapi.h:1101
static LPOLESTR
Definition: stg_prop.c:27
HRESULT SHELL32_BindToSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidl, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: shlfolder.cpp:159
HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, IDataObject **dataObject)
HRESULT GetFindData([out] WIN32_FIND_DATAW *pfd)
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1720
#define PathAppend
Definition: shlwapi.h:801
HRESULT WINAPI SHCreateShellFolderView(const SFV_CREATE *pcsfv, IShellView **ppsv)
Definition: CDefView.cpp:3446
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
#define DWORD
Definition: nt_native.h:44
STRRET str
Definition: shtypes.idl:108
int32_t INT
Definition: typedefs.h:56
virtual HRESULT WINAPI GetClassID(CLSID *lpClassId)
Definition: CFSFolder.cpp:1354
WPARAM wParam
Definition: combotst.c:138
#define SFVM_GET_CUSTOMVIEWINFO
#define IDS_SHV_COLUMN_TYPE
Definition: resource.h:75
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:1094
#define lstrcpynW
Definition: compat.h:397
static HRESULT getIconLocationForFolder(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags, LPWSTR szIconFile, UINT cchMax, int *piIndex, UINT *pwFlags)
Definition: CFSFolder.cpp:165
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:121
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
#define __SHFreeAndNil(ptr)
Definition: shell32_main.h:136
STAR * stars
Definition: screensaver.c:45
UINT WINAPI GetPrivateProfileIntW(LPCWSTR section, LPCWSTR entry, INT def_val, LPCWSTR filename)
Definition: profile.c:1297
#define IDS_SHV_COLUMN_SIZE
Definition: shresdef.h:44
char cStr[MAX_PATH]
Definition: shtypes.idl:98
IShellFolder * psf
Definition: shlobj.h:2343
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
TCHAR szIniFile[]
Definition: scrnsave.c:28
unsigned char * LPBYTE
Definition: typedefs.h:52
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define MFS_ENABLED
Definition: winuser.h:745
#define UNICODE_NULL
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
static const WCHAR szText[]
Definition: dialog.c:139
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:818
HRESULT CFSExtractIcon_CreateInstance(IShellFolder *psf, LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:247
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:289
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
BOOL SHELL_FS_HideExtension(LPWSTR szPath)
Definition: CFSFolder.cpp:1074
#define GET_SHGDN_FOR(dwFlags)
Definition: precomp.h:52
HRESULT _ILCreateFromPathW(LPCWSTR szPath, LPITEMIDLIST *ppidl)
Definition: pidl.c:1775
HRESULT SHELL32_CompareChildren(IShellFolder2 *psf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:215
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1044
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
static HBITMAP DoLoadPicture(LPCWSTR pszFileName)
Definition: CFSFolder.cpp:1631
#define pp
Definition: hlsl.yy.c:978
ULONG Release()
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT GetAttributesOf([in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in, out] SFGAOF *rgfInOut)
DWORD _ILGetFileSize(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2441
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:1951
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
HRESULT WINAPI OleLoadPicture(LPSTREAM lpstream, LONG lSize, BOOL fRunmode, REFIID riid, LPVOID *ppvObj)
Definition: olepicture.c:2352
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2462
LONG_PTR LPARAM
Definition: windef.h:208
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
UINT indexMenu
Definition: shlobj.h:1307
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
HRESULT SHELL32_GetDisplayNameOfChild(IShellFolder2 *psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
Definition: shlfolder.cpp:197
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2082
struct _SFV_CREATE SFV_CREATE
HRESULT _GetIconHandler(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:1548
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:91
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:442
static WCHAR szElement[]
Definition: domdoc.c:1171
HRESULT WINAPI SHCoCreateInstance(LPCWSTR aclsid, const CLSID *clsid, LPUNKNOWN pUnkOuter, REFIID refiid, LPVOID *ppv)
Definition: shellole.c:105
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HRESULT GetObjectParam([in] LPOLESTR pszKey, [out] IUnknown **ppunk)
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
BOOL WINAPI _ILIsPidlSimple(LPCITEMIDLIST pidl)
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
HRESULT SHELL32_ParseNextElement(IShellFolder2 *psf, HWND hwndOwner, LPBC pbc, LPITEMIDLIST *pidlInOut, LPOLESTR szNext, DWORD *pEaten, DWORD *pdwAttributes)
Definition: shlfolder.cpp:70
HRESULT SHELL32_CompareDetails(IShellFolder2 *isf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:238
#define STGM_READ
Definition: objbase.h:916
virtual HRESULT WINAPI GetDefaultSearchGUID(GUID *pguid)
Definition: CFSFolder.cpp:1250
virtual HRESULT WINAPI GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
Definition: CFSFolder.cpp:1262
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:541
virtual HRESULT WINAPI GetCurFolder(LPITEMIDLIST *pidl)
Definition: CFSFolder.cpp:1401
int OLE_HANDLE
Definition: olepro.idl:76
static IFileSystemBindData fsbd
Definition: shlfolder.c:4672
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
DWORD m_bGroupPolicyActive
Definition: CFSFolder.h:42
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MM_ADDSEPARATOR
Definition: shlobj.h:2319
LONG HRESULT
Definition: typedefs.h:77
DWORD COLORREF
Definition: windef.h:285
LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path)
Definition: CFSFolder.cpp:460
UINT idCmdFirst
Definition: shlobj.h:1308
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
GLfloat param
Definition: glext.h:5796
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4272
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
HKEY OpenKeyFromFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName)
Definition: CFSFolder.cpp:28
#define DFM_MERGECONTEXTMENU
Definition: precomp.h:44
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2389
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ PSTRING FullName
Definition: rtlfuncs.h:1649
BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
Definition: fprop.cpp:94
Definition: id3.c:18
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
virtual HRESULT WINAPI GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut)
Definition: CFSFolder.cpp:979
HRESULT WINAPI SHCreateStreamOnFileEx(LPCWSTR lpszPath, DWORD dwMode, DWORD dwAttributes, BOOL bCreate, IStream *lpTemplate, IStream **lppStream)
Definition: istream.c:401
GLbitfield flags
Definition: glext.h:7161
UINT cchMax
BOOL _ILIsDrive(LPCITEMIDLIST pidl)
Definition: pidl.c:1939
LPCWSTR GetNextElementW(LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut)
Definition: shlfolder.cpp:43
virtual HRESULT WINAPI ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, DWORD *pchEaten, PIDLIST_RELATIVE *ppidl, DWORD *pdwAttributes)
Definition: CFSFolder.cpp:592
DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len) DECLSPEC_HIDDEN
Definition: shellord.c:113
CLSID * pclsid
Definition: CFSFolder.h:35
virtual HRESULT WINAPI BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:702
#define IDI_SHELL_FOLDER
Definition: shresdef.h:467
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1461
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
REFCLSID clsid
Definition: msctf.c:84
static const WCHAR L[]
Definition: oid.c:1250
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
const GUID IID_IPicture
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:1960
WINE_DEFAULT_DEBUG_CHANNEL(shell)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
virtual HRESULT WINAPI GetFolderTargetInfo(PERSIST_FOLDER_TARGET_INFO *ppfti)
Definition: CFSFolder.cpp:1487
void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
Definition: changenotify.c:340
_In_ HANDLE hFile
Definition: mswsock.h:90
#define IDS_SHV_COLUMN_MODIFIED
Definition: shresdef.h:46
#define wcsicmp
Definition: string.h:1152
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
virtual HRESULT WINAPI CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:847
static const shvheader GenericSFHeader[]
Definition: CFSFolder.cpp:442
SFGAO_STORAGEANCESTOR typedef ULONG SFGAOF
Definition: shobjidl.idl:213
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define SHCNF_PATHW
Definition: shlobj.h:1755
static const WCHAR HideFileExtW[]
Definition: CFSFolder.cpp:1058
int WINAPI PathParseIconLocationW(LPWSTR lpszPath)
Definition: path.c:1087
#define ERR(fmt,...)
Definition: debug.h:109
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
void SHELL_FS_ProcessDisplayFilename(LPWSTR szPath, DWORD dwFlags)
Definition: CFSFolder.cpp:1105
#define S_OK
Definition: intsafe.h:59
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2336
HRESULT GetCLSIDForFileType(PCUIDLIST_RELATIVE pidl, LPCWSTR KeyName, CLSID *pclsid)
Definition: CFSFolder.cpp:78
virtual HRESULT WINAPI SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
Definition: CFSFolder.cpp:1186
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2566
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1323
BOOL _ILGetFileDate(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2397
LPWSTR sPathTarget
Definition: CFSFolder.h:38
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
LPCWSTR szPath
Definition: env.c:35
void AddFSClassKeysToArray(PCUITEMID_CHILD pidl, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:281
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:561
virtual HRESULT WINAPI GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet)
Definition: CFSFolder.cpp:1128
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:248
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
#define E_NOTIMPL
Definition: ddrawi.h:99
#define LR_CREATEDIBSECTION
Definition: winuser.h:1088
Definition: services.c:325
#define sprintfW
Definition: unicode.h:58
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
VOID WINAPI PathUnquoteSpacesW(LPWSTR lpszPath)
Definition: path.c:1029
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int UINT
Definition: ndis.h:50
#define CSIDL_FLAG_CREATE
#define IMAGE_BITMAP
Definition: winuser.h:211
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
virtual HRESULT WINAPI EnumSearches(IEnumExtraSearch **ppenum)
Definition: CFSFolder.cpp:1256
void SHELL32_GetCLSIDForDirectory(LPCWSTR pwszDir, CLSID *pclsidFolder)
Definition: CFSFolder.cpp:493
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:846
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *wfd)
Definition: pidl.c:1727
void _ILGetFileType(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
Definition: pidl.c:2508
DWORD dwFileAttributes
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
GLuint res
Definition: glext.h:9613
uint32_t * LPDWORD
Definition: typedefs.h:57
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2247
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
virtual HRESULT WINAPI BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:774
IUnknown * punkAssociationInfo
Definition: shlobj.h:2346
static const WCHAR s_shellClassInfo[]
Definition: CFSFolder.cpp:156
#define PT_FOLDER
Definition: pidl.h:94
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
static HBITMAP
Definition: button.c:44
#define GENERICSHELLVIEWCOLUMNS
Definition: CFSFolder.cpp:451
static const WCHAR AdvancedW[]
Definition: CFSFolder.cpp:1057
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
virtual HRESULT WINAPI GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags)
Definition: CFSFolder.cpp:1275
#define END_COM_MAP()
Definition: atlcom.h:552
#define IDS_SHV_COLUMN_NAME
Definition: resource.h:74
WCHAR * LPWSTR
Definition: xmlstorage.h:184
virtual HRESULT WINAPI GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut)
Definition: CFSFolder.cpp:899
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define wsprintf
Definition: winuser.h:5731
UINT uType
Definition: shtypes.idl:93
#define E_POINTER
Definition: winerror.h:2365
LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile)
Definition: path.c:189
PCUITEMID_CHILD_ARRAY apidl
Definition: shlobj.h:2345
GLuint64EXT * result
Definition: glext.h:11304
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
virtual HRESULT WINAPI InitializeEx(IBindCtx *pbc, LPCITEMIDLIST pidlRoot, const PERSIST_FOLDER_TARGET_INFO *ppfti)
Definition: CFSFolder.cpp:1417
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
PCIDLIST_ABSOLUTE pidlFolder
Definition: shlobj.h:2342
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define IDS_SHV_COLUMN_ATTRIBUTES
Definition: shresdef.h:47
base of all file and directory entries
Definition: entries.h:82
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
LPITEMIDLIST pidlRoot
Definition: CFSFolder.h:40
HRESULT SHELL32_GetFSItemAttributes(IShellFolder *psf, LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
Definition: CFSFolder.cpp:511
HRESULT _CreateExtensionUIObject(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppvOut)
Definition: CFSFolder.cpp:1494
#define SUCCEEDED(hr)
Definition: intsafe.h:57
virtual HRESULT WINAPI CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2)
Definition: CFSFolder.cpp:791
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
virtual HRESULT WINAPI CallBack(IShellFolder *psf, HWND hwndOwner, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CFSFolder.cpp:1594
virtual HRESULT WINAPI MessageSFVCB(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CFSFolder.cpp:1746
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
HRESULT WINAPI GetCustomViewInfo(ULONG unknown, SFVM_CUSTOMVIEWINFO_DATA *data)
Definition: CFSFolder.cpp:1658