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 /* Undocumented functions from shdocvw */
59 extern HRESULT WINAPI IEParseDisplayNameWithBCW(DWORD codepage, LPCWSTR lpszDisplayName, LPBC pbc, LPITEMIDLIST *ppidl);
62 /***********************************************************************
63 * Desktopfolder implementation
67 const IShellFolder2Vtbl *lpVtbl;
70 /* both paths are parsible from the desktop */
71 LPWSTR sPathTarget; /* complete path to target used for enumeration and ChangeNotify */
72 LPITEMIDLIST pidlRoot; /* absolute pidl */
74 UINT cfShellIDList; /* clipboardformat for IDropTarget */
75 BOOL fAcceptFmt; /* flag for pending Drop */
78 #define _IUnknown_(This) (IShellFolder*)&(This->lpVtbl)
79 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
81 static const shvheader DesktopSFHeader[] = {
82 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
83 {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
84 {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
85 {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
86 {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
89 #define DESKTOPSHELLVIEWCOLUMNS 5
91 /**************************************************************************
92 * ISF_Desktop_fnQueryInterface
94 * NOTES supports not IPersist/IPersistFolder
96 static HRESULT WINAPI ISF_Desktop_fnQueryInterface(
97 IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
99 IGenericSFImpl *This = (IGenericSFImpl *)iface;
101 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
105 if (IsEqualIID (riid, &IID_IUnknown) ||
106 IsEqualIID (riid, &IID_IShellFolder) ||
107 IsEqualIID (riid, &IID_IShellFolder2))
114 IUnknown_AddRef ((IUnknown *) (*ppvObj));
115 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
118 TRACE ("-- Interface: E_NOINTERFACE\n");
119 return E_NOINTERFACE;
122 static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
124 return 2; /* non-heap based object */
127 static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
129 return 1; /* non-heap based object */
132 /**************************************************************************
133 * ISF_Desktop_fnParseDisplayName
136 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
139 static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
140 HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
141 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
143 IGenericSFImpl *This = (IGenericSFImpl *)iface;
144 WCHAR szElement[MAX_PATH];
145 LPCWSTR szNext = NULL;
146 LPITEMIDLIST pidlTemp = NULL;
150 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
151 This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName),
152 pchEaten, ppidl, pdwAttributes);
154 if (!lpszDisplayName || !ppidl)
160 *pchEaten = 0; /* strange but like the original */
162 if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':')
164 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
165 TRACE ("-- element: %s\n", debugstr_w (szElement));
166 SHCLSIDFromStringW (szElement + 2, &clsid);
167 pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
169 else if (PathGetDriveNumberW (lpszDisplayName) >= 0)
171 /* it's a filesystem path with a drive. Let MyComputer/UnixDosFolder parse it */
172 if (UNIXFS_is_rooted_at_desktop())
173 pidlTemp = _ILCreateGuid(PT_GUID, &CLSID_UnixDosFolder);
175 pidlTemp = _ILCreateMyComputer ();
176 szNext = lpszDisplayName;
178 else if (PathIsUNCW(lpszDisplayName))
180 pidlTemp = _ILCreateNetwork();
181 szNext = lpszDisplayName;
183 else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) )
188 else if (strchrW(lpszDisplayName,':'))
190 return IEParseDisplayNameWithBCW(CP_ACP,lpszDisplayName,pbc,ppidl);
194 /* it's a filesystem path on the desktop. Let a FSFolder parse it */
196 if (*lpszDisplayName)
198 WCHAR szPath[MAX_PATH];
201 /* build a complete path to create a simple pidl */
202 lstrcpynW(szPath, This->sPathTarget, MAX_PATH);
203 pathPtr = PathAddBackslashW(szPath);
206 lstrcpynW(pathPtr, lpszDisplayName, MAX_PATH - (pathPtr - szPath));
207 hr = _ILCreateFromPathW(szPath, &pidlTemp);
211 /* should never reach here, but for completeness */
212 hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
216 pidlTemp = _ILCreateMyComputer();
221 if (SUCCEEDED(hr) && pidlTemp)
223 if (szNext && *szNext)
225 hr = SHELL32_ParseNextElement(iface, hwndOwner, pbc,
226 &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
230 if (pdwAttributes && *pdwAttributes)
231 hr = SHELL32_GetItemAttributes(_IShellFolder_ (This),
232 pidlTemp, pdwAttributes);
238 TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
243 /**************************************************************************
244 * CreateDesktopEnumList()
246 static const WCHAR Desktop_NameSpaceW[] = { 'S','O','F','T','W','A','R','E',
247 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
248 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
249 'o','r','e','r','\\','D','e','s','k','t','o','p','\\','N','a','m','e','s','p',
252 static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
255 WCHAR szPath[MAX_PATH];
257 TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
259 /* enumerate the root folders */
260 if (dwFlags & SHCONTF_FOLDERS)
265 /* create the pidl for This item */
266 ret = AddToEnumList(list, _ILCreateMyComputer());
268 for (i=0; i<2; i++) {
269 if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
270 Desktop_NameSpaceW, 0, KEY_READ, &hkey))
280 size = sizeof (iid) / sizeof (iid[0]);
281 r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
282 if (ERROR_SUCCESS == r)
284 ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid));
287 else if (ERROR_NO_MORE_ITEMS == r)
297 /* enumerate the elements in %windir%\desktop */
298 SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
299 ret = ret && CreateFolderEnumList(list, szPath, dwFlags);
304 /**************************************************************************
305 * ISF_Desktop_fnEnumObjects
307 static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
308 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
310 IGenericSFImpl *This = (IGenericSFImpl *)iface;
312 TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n",
313 This, hwndOwner, dwFlags, ppEnumIDList);
315 *ppEnumIDList = IEnumIDList_Constructor();
317 CreateDesktopEnumList(*ppEnumIDList, dwFlags);
319 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
321 return *ppEnumIDList ? S_OK : E_OUTOFMEMORY;
324 /**************************************************************************
325 * ISF_Desktop_fnBindToObject
327 static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface,
328 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
330 IGenericSFImpl *This = (IGenericSFImpl *)iface;
332 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n",
333 This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
335 return SHELL32_BindToChild( This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut );
338 /**************************************************************************
339 * ISF_Desktop_fnBindToStorage
341 static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface,
342 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
344 IGenericSFImpl *This = (IGenericSFImpl *)iface;
346 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n",
347 This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
353 /**************************************************************************
354 * ISF_Desktop_fnCompareIDs
356 static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface,
357 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
359 IGenericSFImpl *This = (IGenericSFImpl *)iface;
362 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
363 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
364 TRACE ("-- %i\n", nReturn);
368 /**************************************************************************
369 * ISF_Desktop_fnCreateViewObject
371 static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface,
372 HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
374 IGenericSFImpl *This = (IGenericSFImpl *)iface;
375 LPSHELLVIEW pShellView;
376 HRESULT hr = E_INVALIDARG;
378 TRACE ("(%p)->(hwnd=%p,%s,%p)\n",
379 This, hwndOwner, shdebugstr_guid (riid), ppvOut);
386 if (IsEqualIID (riid, &IID_IDropTarget))
388 WARN ("IDropTarget not implemented\n");
391 else if (IsEqualIID (riid, &IID_IContextMenu))
393 WARN ("IContextMenu not implemented\n");
396 else if (IsEqualIID (riid, &IID_IShellView))
398 pShellView = IShellView_Constructor ((IShellFolder *) iface);
401 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
402 IShellView_Release (pShellView);
405 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
409 /**************************************************************************
410 * ISF_Desktop_fnGetAttributesOf
412 static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
413 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
415 IGenericSFImpl *This = (IGenericSFImpl *)iface;
417 static const DWORD dwDesktopAttributes =
418 SFGAO_STORAGE | SFGAO_HASPROPSHEET | SFGAO_STORAGEANCESTOR |
419 SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_FILESYSTEM | SFGAO_HASSUBFOLDER;
420 static const DWORD dwMyComputerAttributes =
421 SFGAO_CANRENAME | SFGAO_CANDELETE | SFGAO_HASPROPSHEET |
422 SFGAO_DROPTARGET | SFGAO_FILESYSANCESTOR | SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
424 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
425 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
436 *rgfInOut &= dwDesktopAttributes;
438 while (cidl > 0 && *apidl) {
440 if (_ILIsDesktop(*apidl)) {
441 *rgfInOut &= dwDesktopAttributes;
442 } else if (_ILIsMyComputer(*apidl)) {
443 *rgfInOut &= dwMyComputerAttributes;
445 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
451 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
452 *rgfInOut &= ~SFGAO_VALIDATE;
454 TRACE ("-- result=0x%08x\n", *rgfInOut);
459 /**************************************************************************
460 * ISF_Desktop_fnGetUIObjectOf
463 * HWND hwndOwner, //[in ] Parent window for any output
464 * UINT cidl, //[in ] array size
465 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
466 * REFIID riid, //[in ] Requested Interface
467 * UINT* prgfInOut, //[ ] reserved
468 * LPVOID* ppvObject) //[out] Resulting Interface
471 static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
472 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl,
473 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
475 IGenericSFImpl *This = (IGenericSFImpl *)iface;
478 IUnknown *pObj = NULL;
479 HRESULT hr = E_INVALIDARG;
481 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
482 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
489 if (IsEqualIID (riid, &IID_IContextMenu))
492 pObj = (LPUNKNOWN) ISvItemCm_Constructor( (IShellFolder *) iface, This->pidlRoot, apidl, cidl);
494 pObj = (LPUNKNOWN) ISvBgCm_Constructor( (IShellFolder *) iface, TRUE);
497 else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
499 pObj = (LPUNKNOWN) IDataObject_Constructor( hwndOwner,
500 This->pidlRoot, apidl, cidl);
503 else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
505 pidl = ILCombine (This->pidlRoot, apidl[0]);
506 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
510 else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
512 pidl = ILCombine (This->pidlRoot, apidl[0]);
513 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
517 else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
519 hr = IShellFolder_QueryInterface (iface,
520 &IID_IDropTarget, (LPVOID *) & pObj);
522 else if ((IsEqualIID(riid,&IID_IShellLinkW) ||
523 IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1))
525 pidl = ILCombine (This->pidlRoot, apidl[0]);
526 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
532 if (SUCCEEDED(hr) && !pObj)
536 TRACE ("(%p)->hr=0x%08x\n", This, hr);
540 /**************************************************************************
541 * ISF_Desktop_fnGetDisplayNameOf
544 * special case: pidl = null gives desktop-name back
546 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
547 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
549 IGenericSFImpl *This = (IGenericSFImpl *)iface;
553 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
559 pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
561 return E_OUTOFMEMORY;
563 if (_ILIsDesktop (pidl))
565 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
566 (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING))
567 strcpyW(pszPath, This->sPathTarget);
569 HCR_GetClassNameW(&CLSID_ShellDesktop, pszPath, MAX_PATH);
571 else if (_ILIsPidlSimple (pidl))
575 if ((clsid = _ILGetGUIDPointer (pidl)))
577 if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)
579 int bWantsForParsing;
582 * We can only get a filesystem path from a shellfolder if the
583 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
585 * Exception: The MyComputer folder doesn't have this key,
586 * but any other filesystem backed folder it needs it.
588 if (IsEqualIID (clsid, &CLSID_MyComputer))
590 bWantsForParsing = TRUE;
594 /* get the "WantsFORPARSING" flag from the registry */
595 static const WCHAR clsidW[] =
596 { 'C','L','S','I','D','\\',0 };
597 static const WCHAR shellfolderW[] =
598 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
599 static const WCHAR wantsForParsingW[] =
600 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
602 WCHAR szRegPath[100];
605 lstrcpyW (szRegPath, clsidW);
606 SHELL32_GUIDToStringW (clsid, &szRegPath[6]);
607 lstrcatW (szRegPath, shellfolderW);
608 r = SHGetValueW(HKEY_CLASSES_ROOT, szRegPath,
609 wantsForParsingW, NULL, NULL, NULL);
610 if (r == ERROR_SUCCESS)
611 bWantsForParsing = TRUE;
613 bWantsForParsing = FALSE;
616 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
620 * we need the filesystem path to the destination folder.
621 * Only the folder itself can know it
623 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
629 /* parsing name like ::{...} */
632 SHELL32_GUIDToStringW (clsid, &pszPath[2]);
637 /* user friendly name */
638 HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
645 /* file system folder or file rooted at the desktop */
646 if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) &&
647 (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER))
649 lstrcpynW(pszPath, This->sPathTarget, MAX_PATH - 1);
650 PathAddBackslashW(pszPath);
651 cLen = lstrlenW(pszPath);
654 _ILSimpleGetTextW(pidl, pszPath + cLen, MAX_PATH - cLen);
656 if (!_ILIsFolder(pidl))
657 SHELL_FS_ProcessDisplayFilename(pszPath, dwFlags);
662 /* a complex pidl, let the subfolder do the work */
663 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags,
669 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
670 if (GetVersion() & 0x80000000)
672 strRet->uType = STRRET_CSTR;
673 if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
675 strRet->u.cStr[0] = '\0';
676 CoTaskMemFree(pszPath);
680 strRet->uType = STRRET_WSTR;
681 strRet->u.pOleStr = pszPath;
685 CoTaskMemFree(pszPath);
687 TRACE ("-- (%p)->(%s,0x%08x)\n", This,
688 strRet->uType == STRRET_CSTR ? strRet->u.cStr :
689 debugstr_w(strRet->u.pOleStr), hr);
693 /**************************************************************************
694 * ISF_Desktop_fnSetNameOf
695 * Changes the name of a file object or subfolder, possibly changing its item
696 * identifier in the process.
699 * HWND hwndOwner, //[in ] Owner window for output
700 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
701 * LPCOLESTR lpszName, //[in ] the items new display name
702 * DWORD dwFlags, //[in ] SHGNO formatting flags
703 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
705 static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface,
706 HWND hwndOwner, LPCITEMIDLIST pidl, /* simple pidl */
707 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
709 IGenericSFImpl *This = (IGenericSFImpl *)iface;
711 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl,
712 debugstr_w (lpName), dwFlags, pPidlOut);
717 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(IShellFolder2 *iface,
720 IGenericSFImpl *This = (IGenericSFImpl *)iface;
722 FIXME ("(%p)\n", This);
726 static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 *iface,
727 IEnumExtraSearch ** ppenum)
729 IGenericSFImpl *This = (IGenericSFImpl *)iface;
730 FIXME ("(%p)\n", This);
734 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
735 DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
737 IGenericSFImpl *This = (IGenericSFImpl *)iface;
739 TRACE ("(%p)\n", This);
748 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (
749 IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
751 IGenericSFImpl *This = (IGenericSFImpl *)iface;
753 TRACE ("(%p)\n", This);
755 if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
758 *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
763 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
764 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
766 IGenericSFImpl *This = (IGenericSFImpl *)iface;
767 FIXME ("(%p)\n", This);
772 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
773 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
775 IGenericSFImpl *This = (IGenericSFImpl *)iface;
779 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
781 if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
786 psd->fmt = DesktopSFHeader[iColumn].fmt;
787 psd->cxChar = DesktopSFHeader[iColumn].cxChar;
788 psd->str.uType = STRRET_CSTR;
789 LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid,
790 psd->str.u.cStr, MAX_PATH);
794 /* the data from the pidl */
795 psd->str.uType = STRRET_CSTR;
799 hr = IShellFolder_GetDisplayNameOf(iface, pidl,
800 SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
803 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
806 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
809 _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
811 case 4: /* attributes */
812 _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
819 static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (
820 IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
822 IGenericSFImpl *This = (IGenericSFImpl *)iface;
823 FIXME ("(%p)\n", This);
827 static const IShellFolder2Vtbl vt_MCFldr_ShellFolder2 =
829 ISF_Desktop_fnQueryInterface,
830 ISF_Desktop_fnAddRef,
831 ISF_Desktop_fnRelease,
832 ISF_Desktop_fnParseDisplayName,
833 ISF_Desktop_fnEnumObjects,
834 ISF_Desktop_fnBindToObject,
835 ISF_Desktop_fnBindToStorage,
836 ISF_Desktop_fnCompareIDs,
837 ISF_Desktop_fnCreateViewObject,
838 ISF_Desktop_fnGetAttributesOf,
839 ISF_Desktop_fnGetUIObjectOf,
840 ISF_Desktop_fnGetDisplayNameOf,
841 ISF_Desktop_fnSetNameOf,
843 ISF_Desktop_fnGetDefaultSearchGUID,
844 ISF_Desktop_fnEnumSearches,
845 ISF_Desktop_fnGetDefaultColumn,
846 ISF_Desktop_fnGetDefaultColumnState,
847 ISF_Desktop_fnGetDetailsEx,
848 ISF_Desktop_fnGetDetailsOf,
849 ISF_Desktop_fnMapColumnToSCID
852 /**************************************************************************
853 * ISF_Desktop_Constructor
855 HRESULT WINAPI ISF_Desktop_Constructor (
856 IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
858 static IGenericSFImpl *cached_sf;
859 WCHAR szMyPath[MAX_PATH];
861 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
866 return CLASS_E_NOAGGREGATION;
872 if (!SHGetSpecialFolderPathW( 0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE ))
875 sf = LocalAlloc( LMEM_ZEROINIT, sizeof (IGenericSFImpl) );
877 return E_OUTOFMEMORY;
880 sf->lpVtbl = &vt_MCFldr_ShellFolder2;
881 sf->pidlRoot = _ILCreateDesktop(); /* my qualified pidl */
882 sf->sPathTarget = SHAlloc( (lstrlenW(szMyPath) + 1)*sizeof(WCHAR) );
883 lstrcpyW( sf->sPathTarget, szMyPath );
885 if (InterlockedCompareExchangePointer((void *)&cached_sf, sf, NULL) != NULL)
887 /* some other thread already been here */
888 SHFree( sf->pidlRoot );
889 SHFree( sf->sPathTarget );
894 return IUnknown_QueryInterface( _IUnknown_(cached_sf), riid, ppv );