3 * Virtual Desktop Folder
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998, 1999, 2002 Juergen Schmied
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/port.h"
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
45 #include "enumidlist.h"
47 #include "undocshell.h"
48 #include "shell32_main.h"
51 #include "shellfolder.h"
52 #include "wine/debug.h"
56 WINE_DEFAULT_DEBUG_CHANNEL (shell);
58 /***********************************************************************
59 * Desktopfolder implementation
63 const IShellFolder2Vtbl *lpVtbl;
66 /* both paths are parsible from the desktop */
67 LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */
68 LPITEMIDLIST pidlRoot; /* absolute pidl */
70 UINT cfShellIDList; /* clipboardformat for IDropTarget */
71 BOOL fAcceptFmt; /* flag for pending Drop */
74 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
75 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
77 static const shvheader DesktopSFHeader[] = {
78 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
79 {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
80 {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
81 {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
82 {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
85 #define DESKTOPSHELLVIEWCOLUMNS 5
87 /**************************************************************************
88 * ISF_Desktop_fnQueryInterface
90 * NOTES supports not IPersist/IPersistFolder
92 static HRESULT WINAPI ISF_Desktop_fnQueryInterface(
93 IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
95 IGenericSFImpl *This = (IGenericSFImpl *)iface;
97 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
101 if (IsEqualIID (riid, &IID_IUnknown) ||
102 IsEqualIID (riid, &IID_IShellFolder) ||
103 IsEqualIID (riid, &IID_IShellFolder2))
110 IUnknown_AddRef ((IUnknown *) (*ppvObj));
111 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
114 TRACE ("-- Interface: E_NOINTERFACE\n");
115 return E_NOINTERFACE;
118 static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
120 return 2; /* non-heap based object */
123 static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
125 return 1; /* non-heap based object */
128 /**************************************************************************
129 * ISF_Desktop_fnParseDisplayName
132 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
135 static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
136 HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
137 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
139 IGenericSFImpl *This = (IGenericSFImpl *)iface;
140 WCHAR szElement[MAX_PATH];
141 LPCWSTR szNext = NULL;
142 LPITEMIDLIST pidlTemp = NULL;
146 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
147 This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName),
148 pchEaten, ppidl, pdwAttributes);
150 if (!lpszDisplayName || !ppidl)
156 *pchEaten = 0; /* strange but like the original */
158 if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':')
160 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
161 TRACE ("-- element: %s\n", debugstr_w (szElement));
162 SHCLSIDFromStringW (szElement + 2, &clsid);
163 pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
165 else if (PathGetDriveNumberW (lpszDisplayName) >= 0)
167 /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
168 if (UNIXFS_is_rooted_at_desktop())
169 pidlTemp = _ILCreateGuid(PT_GUID, &CLSID_UnixDosFolder);
171 pidlTemp = _ILCreateMyComputer ();
172 szNext = lpszDisplayName;
174 else if (PathIsUNCW(lpszDisplayName))
176 pidlTemp = _ILCreateNetwork();
177 szNext = lpszDisplayName;
179 else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) )
186 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
188 if (*lpszDisplayName)
190 WCHAR szPath[MAX_PATH];
193 /* build a complete path to create a simple pidl */
194 lstrcpynW(szPath, This->sPathTarget, MAX_PATH);
195 pathPtr = PathAddBackslashW(szPath);
198 lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath));
199 hr = _ILCreateFromPathW(szPath, &pidlTemp);
203 /* should never reach here, but for completeness */
204 hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
208 pidlTemp = _ILCreateMyComputer();
213 if (SUCCEEDED(hr) && pidlTemp)
215 if (szNext && *szNext)
217 hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc,
218 &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
222 if (pdwAttributes && *pdwAttributes)
223 hr = SHELL32_GetItemAttributes(_IShellFolder_ (This),
224 pidlTemp, pdwAttributes);
230 TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
235 /**************************************************************************
236 * CreateDesktopEnumList()
238 static const WCHAR Desktop_NameSpaceW[] = { 'S','O','F','T','W','A','R','E',
239 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
240 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
241 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
244 static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
247 WCHAR szPath[MAX_PATH];
249 TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
251 /* enumerate the root folders */
252 if (dwFlags & SHCONTF_FOLDERS)
257 /* create the pidl for This item */
258 ret = AddToEnumList(list, _ILCreateMyComputer());
260 for (i=0; i<2; i++) {
261 if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
262 Desktop_NameSpaceW, 0, KEY_READ, &hkey))
272 size = sizeof (iid) / sizeof (iid[0]);
273 r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
274 if (ERROR_SUCCESS == r)
276 ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid));
279 else if (ERROR_NO_MORE_ITEMS == r)
289 /* enumerate the elements in %windir%\desktop */
290 SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
291 ret = ret && CreateFolderEnumList(list, szPath, dwFlags);
296 /**************************************************************************
297 * ISF_Desktop_fnEnumObjects
299 static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
300 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
302 IGenericSFImpl *This = (IGenericSFImpl *)iface;
304 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
305 This, hwndOwner, dwFlags, ppEnumIDList);
307 *ppEnumIDList = IEnumIDList_Constructor();
309 CreateDesktopEnumList(*ppEnumIDList, dwFlags);
311 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
313 return *ppEnumIDList ? S_OK : E_OUTOFMEMORY;
316 /**************************************************************************
317 * ISF_Desktop_fnBindToObject
319 static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface,
320 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
322 IGenericSFImpl *This = (IGenericSFImpl *)iface;
324 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
325 This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
327 return SHELL32_BindToChild( This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut );
330 /**************************************************************************
331 * ISF_Desktop_fnBindToStorage
333 static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface,
334 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
336 IGenericSFImpl *This = (IGenericSFImpl *)iface;
338 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
339 This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
345 /**************************************************************************
346 * ISF_Desktop_fnCompareIDs
348 static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface,
349 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
351 IGenericSFImpl *This = (IGenericSFImpl *)iface;
354 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
355 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
356 TRACE ("-- %i\n", nReturn);
360 /**************************************************************************
361 * ISF_Desktop_fnCreateViewObject
363 static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface,
364 HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
366 IGenericSFImpl *This = (IGenericSFImpl *)iface;
367 LPSHELLVIEW pShellView;
368 HRESULT hr = E_INVALIDARG;
370 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
371 This, hwndOwner, shdebugstr_guid (riid), ppvOut);
378 if (IsEqualIID (riid, &IID_IDropTarget))
380 WARN ("IDropTarget not implemented\n");
383 else if (IsEqualIID (riid, &IID_IContextMenu))
385 WARN ("IContextMenu not implemented\n");
388 else if (IsEqualIID (riid, &IID_IShellView))
390 pShellView = IShellView_Constructor ((IShellFolder *) iface);
393 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
394 IShellView_Release (pShellView);
397 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
401 /**************************************************************************
402 * ISF_Desktop_fnGetAttributesOf
404 static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
405 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
407 IGenericSFImpl *This = (IGenericSFImpl *)iface;
409 static const DWORD dwDesktopAttributes =
410 SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR |
411 SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
412 static const DWORD dwMyComputerAttributes =
413 SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET |
414 SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
416 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
417 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
428 *rgfInOut &= dwDesktopAttributes;
430 while (cidl > 0 && *apidl) {
432 if (_ILIsDesktop(*apidl)) {
433 *rgfInOut &= dwDesktopAttributes;
434 } else if (_ILIsMyComputer(*apidl)) {
435 *rgfInOut &= dwMyComputerAttributes;
437 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
443 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
444 *rgfInOut &= ~SFGAO_VALIDATE;
446 TRACE ("-- result=0x%08x\n", *rgfInOut);
451 /**************************************************************************
452 * ISF_Desktop_fnGetUIObjectOf
455 * HWND hwndOwner, //[in ] Parent window for any output
456 * UINT cidl, //[in ] array size
457 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
458 * REFIID riid, //[in ] Requested Interface
459 * UINT* prgfInOut, //[ ] reserved
460 * LPVOID* ppvObject) //[out] Resulting Interface
463 static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
464 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl,
465 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
467 IGenericSFImpl *This = (IGenericSFImpl *)iface;
470 IUnknown *pObj = NULL;
471 HRESULT hr = E_INVALIDARG;
473 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
474 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
481 if (IsEqualIID (riid, &IID_IContextMenu))
484 pObj = (LPUNKNOWN) ISvItemCm_Constructor( (IShellFolder *) iface, This->pidlRoot, apidl, cidl);
486 pObj = (LPUNKNOWN) ISvBgCm_Constructor( (IShellFolder *) iface, TRUE);
489 else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
491 pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner,
492 This->pidlRoot, apidl, cidl);
495 else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
497 pidl = ILCombine (This->pidlRoot, apidl[0]);
498 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
502 else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
504 pidl = ILCombine (This->pidlRoot, apidl[0]);
505 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
509 else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
511 hr = IShellFolder_QueryInterface (iface,
512 &IID_IDropTarget, (LPVOID *) & pObj);
514 else if ((IsEqualIID(riid,&IID_IShellLinkW) ||
515 IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1))
517 pidl = ILCombine (This->pidlRoot, apidl[0]);
518 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
524 if (SUCCEEDED(hr) && !pObj)
528 TRACE ("(%p)->hr=0x%08x\n", This, hr);
532 /**************************************************************************
533 * ISF_Desktop_fnGetDisplayNameOf
536 * special case: pidl = null gives desktop-name back
538 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
539 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
541 IGenericSFImpl *This = (IGenericSFImpl *)iface;
545 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
551 pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
553 return E_OUTOFMEMORY;
555 if (_ILIsDesktop (pidl))
557 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
558 (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
559 strcpyW(pszPath, This->sPathTarget);
561 HCR_GetClassNameW(&CLSID_ShellDesktop, pszPath, MAX_PATH);
563 else if (_ILIsPidlSimple (pidl))
567 if ((clsid = _ILGetGUIDPointer (pidl)))
569 if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)
571 int bWantsForParsing;
574 * We can only get a filesystem path from a shellfolder if the
575 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
577 * Exception: The MyComputer folder doesn't have this key,
578 * but any other filesystem backed folder it needs it.
580 if (IsEqualIID (clsid, &CLSID_MyComputer))
582 bWantsForParsing = TRUE;
586 /* get the "WantsFORPARSING" flag from the registry */
587 static const WCHAR clsidW[] =
588 { 'C','L','S','I','D','\\',0 };
589 static const WCHAR shellfolderW[] =
590 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
591 static const WCHAR wantsForParsingW[] =
592 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
594 WCHAR szRegPath[100];
597 lstrcpyW (szRegPath, clsidW);
598 SHELL32_GUIDToStringW (clsid, &szRegPath[6]);
599 lstrcatW (szRegPath, shellfolderW);
600 r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath,
601 wantsForParsingW, NULL, NULL, NULL);
602 if (r == ERROR_SUCCESS)
603 bWantsForParsing = TRUE;
605 bWantsForParsing = FALSE;
608 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
612 * we need the filesystem path to the destination folder.
613 * Only the folder itself can know it
615 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
621 /* parsing name like ::{...} */
624 SHELL32_GUIDToStringW (clsid, &pszPath[2]);
629 /* user friendly name */
630 HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
637 /* file system folder or file rooted at the desktop */
638 if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
639 (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
641 lstrcpynW(pszPath, This->sPathTarget, MAX_PATH - 1);
642 PathAddBackslashW(pszPath);
643 cLen = lstrlenW(pszPath);
646 _ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen);
648 if (!_ILIsFolder(pidl))
649 SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
654 /* a complex pidl, let the subfolder do the work */
655 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
661 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
662 if (GetVersion() & 0x80000000)
664 strRet->uType = STRRET_CSTR;
665 if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
667 strRet->u.cStr[0] = '\0';
668 CoTaskMemFree(pszPath);
672 strRet->uType = STRRET_WSTR;
673 strRet->u.pOleStr = pszPath;
677 CoTaskMemFree(pszPath);
679 TRACE ("-- (%p)->(%s,0x%08x)\n", This,
680 strRet->uType == STRRET_CSTR ? strRet->u.cStr :
681 debugstr_w(strRet->u.pOleStr), hr);
685 /**************************************************************************
686 * ISF_Desktop_fnSetNameOf
687 * Changes the name of a file object or subfolder, possibly changing its item
688 * identifier in the process.
691 * HWND hwndOwner, //[in ] Owner window for output
692 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
693 * LPCOLESTR lpszName, //[in ] the items new display name
694 * DWORD dwFlags, //[in ] SHGNO formatting flags
695 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
697 static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface,
698 HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */
699 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
701 IGenericSFImpl *This = (IGenericSFImpl *)iface;
703 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl,
704 debugstr_w (lpName), dwFlags, pPidlOut);
709 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2 *iface,
712 IGenericSFImpl *This = (IGenericSFImpl *)iface;
714 FIXME ("(%p)\n", This);
718 static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 *iface,
719 IEnumExtraSearch ** ppenum)
721 IGenericSFImpl *This = (IGenericSFImpl *)iface;
722 FIXME ("(%p)\n", This);
726 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
727 DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
729 IGenericSFImpl *This = (IGenericSFImpl *)iface;
731 TRACE ("(%p)\n", This);
740 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (
741 IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
743 IGenericSFImpl *This = (IGenericSFImpl *)iface;
745 TRACE ("(%p)\n", This);
747 if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
750 *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
755 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
756 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
758 IGenericSFImpl *This = (IGenericSFImpl *)iface;
759 FIXME ("(%p)\n", This);
764 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
765 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
767 IGenericSFImpl *This = (IGenericSFImpl *)iface;
771 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
773 if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
778 psd->fmt = DesktopSFHeader[iColumn].fmt;
779 psd->cxChar = DesktopSFHeader[iColumn].cxChar;
780 psd->str.uType = STRRET_CSTR;
781 LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid,
782 psd->str.u.cStr, MAX_PATH);
786 /* the data from the pidl */
787 psd->str.uType = STRRET_CSTR;
791 hr = IShellFolder_GetDisplayNameOf(iface, pidl,
792 SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
795 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
798 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
801 _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
803 case 4: /* attributes */
804 _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
811 static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (
812 IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
814 IGenericSFImpl *This = (IGenericSFImpl *)iface;
815 FIXME ("(%p)\n", This);
819 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2 =
821 ISF_Desktop_fnQueryInterface,
822 ISF_Desktop_fnAddRef,
823 ISF_Desktop_fnRelease,
824 ISF_Desktop_fnParseDisplayName,
825 ISF_Desktop_fnEnumObjects,
826 ISF_Desktop_fnBindToObject,
827 ISF_Desktop_fnBindToStorage,
828 ISF_Desktop_fnCompareIDs,
829 ISF_Desktop_fnCreateViewObject,
830 ISF_Desktop_fnGetAttributesOf,
831 ISF_Desktop_fnGetUIObjectOf,
832 ISF_Desktop_fnGetDisplayNameOf,
833 ISF_Desktop_fnSetNameOf,
835 ISF_Desktop_fnGetDefaultSearchGUID,
836 ISF_Desktop_fnEnumSearches,
837 ISF_Desktop_fnGetDefaultColumn,
838 ISF_Desktop_fnGetDefaultColumnState,
839 ISF_Desktop_fnGetDetailsEx,
840 ISF_Desktop_fnGetDetailsOf,
841 ISF_Desktop_fnMapColumnToSCID
844 /**************************************************************************
845 * ISF_Desktop_Constructor
847 HRESULT WINAPI ISF_Desktop_Constructor (
848 IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
850 static IGenericSFImpl *cached_sf;
851 WCHAR szMyPath[MAX_PATH];
853 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
858 return CLASS_E_NOAGGREGATION;
864 if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE ))
867 sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IGenericSFImpl) );
869 return E_OUTOFMEMORY;
872 sf->lpVtbl = &vt_MCFldr_ShellFolder2;
873 sf->pidlRoot = _ILCreateDesktop(); /* my qualified pidl */
874 sf->sPathTarget = SHAlloc( (lstrlenW(szMyPath) + 1)*sizeof(WCHAR) );
875 lstrcpyW( sf->sPathTarget, szMyPath );
877 if (InterlockedCompareExchangePointer((void *)&cached_sf, sf, NULL) != NULL)
879 /* some other thread already been here */
880 SHFree( sf->pidlRoot );
881 SHFree( sf->sPathTarget );
886 return IUnknown_QueryInterface( _IUnknown_(cached_sf), riid, ppv );