Authors: Mike McCormack <mike@codeweavers.com>, Aric Stewart <aric@codeweavers.com...
[wine] / dlls / shell32 / shfldr_desktop.c
1
2 /*
3  *      Virtual Desktop Folder
4  *
5  *      Copyright 1997                  Marcus Meissner
6  *      Copyright 1998, 1999, 2002      Juergen Schmied
7  *
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.
12  *
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.
17  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24 #include "wine/port.h"
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29 #include <stdio.h>
30
31 #define COBJMACROS
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
34
35 #include "winerror.h"
36 #include "windef.h"
37 #include "winbase.h"
38 #include "winreg.h"
39 #include "wingdi.h"
40 #include "winuser.h"
41
42 #include "ole2.h"
43 #include "shlguid.h"
44
45 #include "enumidlist.h"
46 #include "pidl.h"
47 #include "undocshell.h"
48 #include "shell32_main.h"
49 #include "shresdef.h"
50 #include "shlwapi.h"
51 #include "shellfolder.h"
52 #include "wine/debug.h"
53 #include "debughlp.h"
54 #include "shfldr.h"
55
56 WINE_DEFAULT_DEBUG_CHANNEL (shell);
57
58 /***********************************************************************
59 *       Desktopfolder implementation
60 */
61
62 typedef struct {
63     IShellFolder2Vtbl *lpVtbl;
64     DWORD ref;
65
66     CLSID *pclsid;
67
68     /* both paths are parsible from the desktop */
69     LPSTR sPathTarget;          /* complete path to target used for enumeration and ChangeNotify */
70     LPITEMIDLIST pidlRoot;      /* absolute pidl */
71
72     int dwAttributes;           /* attributes returned by GetAttributesOf FIXME: use it */
73
74     UINT cfShellIDList;         /* clipboardformat for IDropTarget */
75     BOOL fAcceptFmt;            /* flag for pending Drop */
76 } IGenericSFImpl;
77
78 #define _IUnknown_(This)        (IShellFolder*)&(This->lpVtbl)
79 #define _IShellFolder_(This)    (IShellFolder*)&(This->lpVtbl)
80
81 static struct IShellFolder2Vtbl vt_MCFldr_ShellFolder2;
82
83 static shvheader DesktopSFHeader[] = {
84     {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
85     {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
86     {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
87     {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
88     {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
89 };
90
91 #define DESKTOPSHELLVIEWCOLUMNS 5
92
93 /**************************************************************************
94 *       ISF_Desktop_Constructor
95 */
96 HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
97 {
98     IGenericSFImpl *sf;
99     char szMyPath[MAX_PATH];
100
101     TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
102
103     if (!ppv)
104         return E_POINTER;
105     if (pUnkOuter)
106         return CLASS_E_NOAGGREGATION;
107
108     if (!SHGetSpecialFolderPathA (0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE))
109         return E_UNEXPECTED;
110
111     sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
112     if (!sf)
113         return E_OUTOFMEMORY;
114
115     sf->ref = 0;
116     sf->lpVtbl = &vt_MCFldr_ShellFolder2;
117     sf->pidlRoot = _ILCreateDesktop (); /* my qualified pidl */
118     sf->sPathTarget = SHAlloc (strlen (szMyPath) + 1);
119     lstrcpyA (sf->sPathTarget, szMyPath);
120
121     if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
122         IUnknown_Release (_IUnknown_ (sf));
123         return E_NOINTERFACE;
124     }
125
126     TRACE ("--(%p)\n", sf);
127     return S_OK;
128 }
129
130 /**************************************************************************
131  *      ISF_Desktop_fnQueryInterface
132  *
133  * NOTES supports not IPersist/IPersistFolder
134  */
135 static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
136 {
137     IGenericSFImpl *This = (IGenericSFImpl *)iface;
138
139     TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
140
141     *ppvObj = NULL;
142
143     if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IShellFolder)
144         || IsEqualIID (riid, &IID_IShellFolder2)) {
145         *ppvObj = This;
146     }
147
148     if (*ppvObj) {
149         IUnknown_AddRef ((IUnknown *) (*ppvObj));
150         TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
151         return S_OK;
152     }
153     TRACE ("-- Interface: E_NOINTERFACE\n");
154     return E_NOINTERFACE;
155 }
156
157 static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
158 {
159     IGenericSFImpl *This = (IGenericSFImpl *)iface;
160     ULONG refCount = InterlockedIncrement(&This->ref);
161
162     TRACE ("(%p)->(count=%lu)\n", This, refCount - 1);
163
164     return refCount;
165 }
166
167 static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
168 {
169     IGenericSFImpl *This = (IGenericSFImpl *)iface;
170     ULONG refCount = InterlockedDecrement(&This->ref);
171
172     TRACE ("(%p)->(count=%lu)\n", This, refCount + 1);
173
174     if (!refCount) {
175         TRACE ("-- destroying IShellFolder(%p)\n", This);
176         if (This->pidlRoot)
177             SHFree (This->pidlRoot);
178         if (This->sPathTarget)
179             SHFree (This->sPathTarget);
180         LocalFree ((HLOCAL) This);
181         return 0;
182     }
183     return refCount;
184 }
185
186 /**************************************************************************
187 *       ISF_Desktop_fnParseDisplayName
188 *
189 * NOTES
190 *       "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
191 *       to MyComputer
192 */
193 static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
194                                                       HWND hwndOwner,
195                                                       LPBC pbc,
196                                                       LPOLESTR lpszDisplayName,
197                                                       DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
198 {
199     IGenericSFImpl *This = (IGenericSFImpl *)iface;
200
201     WCHAR szElement[MAX_PATH];
202     LPCWSTR szNext = NULL;
203     LPITEMIDLIST pidlTemp = NULL;
204     HRESULT hr = S_OK;
205     char szPath[MAX_PATH];
206     DWORD len;
207     CLSID clsid;
208
209     TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
210            This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
211
212     if (!lpszDisplayName || !ppidl)
213         return E_INVALIDARG;
214
215     *ppidl = 0;
216
217     if (pchEaten)
218         *pchEaten = 0;          /* strange but like the original */
219
220     if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') {
221         szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
222         TRACE ("-- element: %s\n", debugstr_w (szElement));
223         SHCLSIDFromStringW (szElement + 2, &clsid);
224         pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
225     } else if (PathGetDriveNumberW (lpszDisplayName) >= 0) {
226         /* it's a filesystem path with a drive. Let MyComputer parse it */
227         pidlTemp = _ILCreateMyComputer ();
228         szNext = lpszDisplayName;
229     } else if (PathIsUNCW(lpszDisplayName)) {
230         pidlTemp = _ILCreateNetwork();
231         szNext = lpszDisplayName;
232     } else {
233         /* it's a filesystem path on the desktop. Let a FSFolder parse it */
234
235         if (*lpszDisplayName) {
236             /* build a complete path to create a simple pidl */
237             lstrcpyA(szPath, This->sPathTarget);
238             PathAddBackslashA(szPath);
239             len = lstrlenA(szPath);
240             WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL);
241             hr = _ILCreateFromPathA(szPath, &pidlTemp);
242         } else {
243             pidlTemp = _ILCreateMyComputer();
244         }
245
246         szNext = NULL;
247     }
248
249     if (SUCCEEDED(hr) && pidlTemp) {
250         if (szNext && *szNext) {
251             hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
252         } else {
253             if (pdwAttributes && *pdwAttributes) {
254                 hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
255             }
256         }
257     }
258
259     *ppidl = pidlTemp;
260
261     TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
262
263     return hr;
264 }
265
266 /**************************************************************************
267  *  CreateDesktopEnumList()
268  */
269 static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
270 {
271     BOOL ret = TRUE;
272     char szPath[MAX_PATH];
273
274     TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags);
275
276     /*enumerate the root folders */
277     if(dwFlags & SHCONTF_FOLDERS)
278     {
279         HKEY hkey;
280
281         /*create the pidl for This item */
282         ret = AddToEnumList(list, _ILCreateMyComputer());
283
284         if (ret && !RegOpenKeyExA(HKEY_LOCAL_MACHINE,
285          "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\desktop\\NameSpace",
286          0, KEY_READ, &hkey))
287         {
288             char iid[50];
289             int i=0;
290             BOOL moreKeys = TRUE;
291
292             while (ret && moreKeys)
293             {
294                 DWORD size = sizeof (iid);
295                 LONG apiRet = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL,
296                  NULL);
297
298                 if (ERROR_SUCCESS == apiRet)
299                 {
300                     ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid));
301                     i++;
302                 }
303                 else if (ERROR_NO_MORE_ITEMS == apiRet)
304                     moreKeys = FALSE;
305                 else
306                     ret = FALSE;
307             }
308             RegCloseKey(hkey);
309         }
310     }
311
312     /*enumerate the elements in %windir%\desktop */
313     SHGetSpecialFolderPathA(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
314     ret = ret && CreateFolderEnumList(list, szPath, dwFlags);
315
316     return ret;
317 }
318
319 /**************************************************************************
320 *               ISF_Desktop_fnEnumObjects
321 */
322 static HRESULT WINAPI ISF_Desktop_fnEnumObjects (IShellFolder2 * iface,
323                                                  HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
324 {
325     IGenericSFImpl *This = (IGenericSFImpl *)iface;
326
327     TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
328
329     *ppEnumIDList = IEnumIDList_Constructor();
330     if (*ppEnumIDList)
331         CreateDesktopEnumList(*ppEnumIDList, dwFlags);
332
333     TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
334
335     return *ppEnumIDList ? S_OK : E_OUTOFMEMORY;
336 }
337
338 /**************************************************************************
339 *               ISF_Desktop_fnBindToObject
340 */
341 static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface,
342                                                   LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
343 {
344     IGenericSFImpl *This = (IGenericSFImpl *)iface;
345
346     TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
347
348     return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut);
349 }
350
351 /**************************************************************************
352 *       ISF_Desktop_fnBindToStorage
353 */
354 static HRESULT WINAPI ISF_Desktop_fnBindToStorage (IShellFolder2 * iface,
355                                                    LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
356 {
357     IGenericSFImpl *This = (IGenericSFImpl *)iface;
358
359     FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
360
361     *ppvOut = NULL;
362     return E_NOTIMPL;
363 }
364
365 /**************************************************************************
366 *       ISF_Desktop_fnCompareIDs
367 */
368
369 static HRESULT WINAPI ISF_Desktop_fnCompareIDs (IShellFolder2 * iface,
370                                                 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
371 {
372     IGenericSFImpl *This = (IGenericSFImpl *)iface;
373
374     int nReturn;
375
376     TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
377     nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
378     TRACE ("-- %i\n", nReturn);
379     return nReturn;
380 }
381
382 /**************************************************************************
383 *       ISF_Desktop_fnCreateViewObject
384 */
385 static HRESULT WINAPI ISF_Desktop_fnCreateViewObject (IShellFolder2 * iface,
386                                                       HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
387 {
388     IGenericSFImpl *This = (IGenericSFImpl *)iface;
389
390     LPSHELLVIEW pShellView;
391     HRESULT hr = E_INVALIDARG;
392
393     TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut);
394
395     if (ppvOut) {
396         *ppvOut = NULL;
397
398         if (IsEqualIID (riid, &IID_IDropTarget)) {
399             WARN ("IDropTarget not implemented\n");
400             hr = E_NOTIMPL;
401         } else if (IsEqualIID (riid, &IID_IContextMenu)) {
402             WARN ("IContextMenu not implemented\n");
403             hr = E_NOTIMPL;
404         } else if (IsEqualIID (riid, &IID_IShellView)) {
405             pShellView = IShellView_Constructor ((IShellFolder *) iface);
406             if (pShellView) {
407                 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
408                 IShellView_Release (pShellView);
409             }
410         }
411     }
412     TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
413     return hr;
414 }
415
416 /**************************************************************************
417 *  ISF_Desktop_fnGetAttributesOf
418 */
419 static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf (IShellFolder2 * iface,
420                                                      UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
421 {
422     IGenericSFImpl *This = (IGenericSFImpl *)iface;
423
424     HRESULT hr = S_OK;
425
426     TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
427
428     if ((!cidl) || (!apidl) || (!rgfInOut))
429         return E_INVALIDARG;
430
431     if (*rgfInOut == 0)
432         *rgfInOut = ~0;
433
434     while (cidl > 0 && *apidl) {
435         pdump (*apidl);
436         SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
437         apidl++;
438         cidl--;
439     }
440
441     TRACE ("-- result=0x%08lx\n", *rgfInOut);
442
443     return hr;
444 }
445
446 /**************************************************************************
447 *       ISF_Desktop_fnGetUIObjectOf
448 *
449 * PARAMETERS
450 *  HWND           hwndOwner, //[in ] Parent window for any output
451 *  UINT           cidl,      //[in ] array size
452 *  LPCITEMIDLIST* apidl,     //[in ] simple pidl array
453 *  REFIID         riid,      //[in ] Requested Interface
454 *  UINT*          prgfInOut, //[   ] reserved
455 *  LPVOID*        ppvObject) //[out] Resulting Interface
456 *
457 */
458 static HRESULT WINAPI ISF_Desktop_fnGetUIObjectOf (IShellFolder2 * iface,
459                                                    HWND hwndOwner,
460                                                    UINT cidl,
461                                                    LPCITEMIDLIST * apidl,
462                                                    REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
463 {
464     IGenericSFImpl *This = (IGenericSFImpl *)iface;
465
466     LPITEMIDLIST pidl;
467     IUnknown *pObj = NULL;
468     HRESULT hr = E_INVALIDARG;
469
470     TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
471            This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
472
473     if (ppvOut) {
474         *ppvOut = NULL;
475
476         if (IsEqualIID (riid, &IID_IContextMenu)) {
477             pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
478             hr = S_OK;
479         } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
480             pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
481             hr = S_OK;
482         } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
483             pidl = ILCombine (This->pidlRoot, apidl[0]);
484             pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
485             SHFree (pidl);
486             hr = S_OK;
487         } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
488             pidl = ILCombine (This->pidlRoot, apidl[0]);
489             pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
490             SHFree (pidl);
491             hr = S_OK;
492         } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
493             hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
494         } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
495                                 && (cidl == 1)) {
496             pidl = ILCombine (This->pidlRoot, apidl[0]);
497             hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
498             SHFree (pidl);
499         } else {
500             hr = E_NOINTERFACE;
501         }
502
503         if (SUCCEEDED(hr) && !pObj)
504             hr = E_OUTOFMEMORY;
505
506         *ppvOut = pObj;
507     }
508     TRACE ("(%p)->hr=0x%08lx\n", This, hr);
509     return hr;
510 }
511
512 /**************************************************************************
513 *       ISF_Desktop_fnGetDisplayNameOf
514 *
515 * NOTES
516 *       special case: pidl = null gives desktop-name back
517 */
518 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
519                                                       LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
520 {
521     IGenericSFImpl *This = (IGenericSFImpl *)iface;
522
523     CHAR szPath[MAX_PATH];
524     GUID const *clsid;
525     HRESULT hr = S_OK;
526
527     *szPath = '\0';
528
529     TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
530     pdump (pidl);
531
532     if (!strRet)
533         return E_INVALIDARG;
534
535     if (_ILIsDesktop (pidl)) {
536         if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) {
537             lstrcpyA (szPath, This->sPathTarget);
538         } else {
539             HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH);
540         }
541     } else if (_ILIsPidlSimple (pidl)) {
542         if ((clsid = _ILGetGUIDPointer (pidl))) {
543             if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
544                 int bWantsForParsing;
545
546                 /*
547                  * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
548                  * CLSID\\{...}\\shellfolder exists
549                  * exception: the MyComputer folder has this keys not but like any filesystem backed
550                  *            folder it needs these behaviour
551                  */
552                 if (IsEqualIID (clsid, &CLSID_MyComputer)) {
553                     bWantsForParsing = 1;
554                 } else {
555                     /* get the "WantsFORPARSING" flag from the registry */
556                     char szRegPath[100];
557
558                     lstrcpyA (szRegPath, "CLSID\\");
559                     SHELL32_GUIDToStringA (clsid, &szRegPath[6]);
560                     lstrcatA (szRegPath, "\\shellfolder");
561                     bWantsForParsing =
562                         (ERROR_SUCCESS ==
563                          SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
564                 }
565
566                 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
567                     /* we need the filesystem path to the destination folder. Only the folder itself can know it */
568                     hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
569                 } else {
570                     /* parsing name like ::{...} */
571                     lstrcpyA (szPath, "::");
572                     SHELL32_GUIDToStringA (clsid, &szPath[2]);
573                 }
574             } else {
575                 /* user friendly name */
576                 HCR_GetClassNameA (clsid, szPath, MAX_PATH);
577             }
578         } else {
579             /* file system folder */
580             _ILSimpleGetText (pidl, szPath, MAX_PATH);
581
582             if (!_ILIsFolder(pidl))
583                 SHELL_FS_ProcessDisplayFilename(szPath, dwFlags);
584         }
585     } else {
586         /* a complex pidl, let the subfolder do the work */
587         hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
588     }
589
590     if (SUCCEEDED (hr)) {
591         strRet->uType = STRRET_CSTR;
592         lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
593     }
594
595     TRACE ("-- (%p)->(%s,0x%08lx)\n", This, szPath, hr);
596     return hr;
597 }
598
599 /**************************************************************************
600 *  ISF_Desktop_fnSetNameOf
601 *  Changes the name of a file object or subfolder, possibly changing its item
602 *  identifier in the process.
603 *
604 * PARAMETERS
605 *  HWND          hwndOwner,  //[in ] Owner window for output
606 *  LPCITEMIDLIST pidl,       //[in ] simple pidl of item to change
607 *  LPCOLESTR     lpszName,   //[in ] the items new display name
608 *  DWORD         dwFlags,    //[in ] SHGNO formatting flags
609 *  LPITEMIDLIST* ppidlOut)   //[out] simple pidl returned
610 */
611 static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,       /*simple pidl */
612                                                LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
613 {
614     IGenericSFImpl *This = (IGenericSFImpl *)iface;
615
616     FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
617
618     return E_FAIL;
619 }
620
621 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
622 {
623     IGenericSFImpl *This = (IGenericSFImpl *)iface;
624
625     FIXME ("(%p)\n", This);
626     return E_NOTIMPL;
627 }
628 static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
629 {
630     IGenericSFImpl *This = (IGenericSFImpl *)iface;
631     FIXME ("(%p)\n", This);
632     return E_NOTIMPL;
633 }
634 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
635                                                       DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
636 {
637     IGenericSFImpl *This = (IGenericSFImpl *)iface;
638
639     TRACE ("(%p)\n", This);
640
641     if (pSort)
642         *pSort = 0;
643     if (pDisplay)
644         *pDisplay = 0;
645
646     return S_OK;
647 }
648 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
649 {
650     IGenericSFImpl *This = (IGenericSFImpl *)iface;
651
652     TRACE ("(%p)\n", This);
653
654     if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
655         return E_INVALIDARG;
656
657     *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
658
659     return S_OK;
660 }
661 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
662                                                   LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
663 {
664     IGenericSFImpl *This = (IGenericSFImpl *)iface;
665     FIXME ("(%p)\n", This);
666
667     return E_NOTIMPL;
668 }
669 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
670                                                   LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
671 {
672     IGenericSFImpl *This = (IGenericSFImpl *)iface;
673
674     HRESULT hr = E_FAIL;
675
676     TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
677
678     if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
679         return E_INVALIDARG;
680
681     if (!pidl) {
682         psd->fmt = DesktopSFHeader[iColumn].fmt;
683         psd->cxChar = DesktopSFHeader[iColumn].cxChar;
684         psd->str.uType = STRRET_CSTR;
685         LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
686         return S_OK;
687     } else {
688         /* the data from the pidl */
689         switch (iColumn) {
690         case 0:         /* name */
691             hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
692             break;
693         case 1:         /* size */
694             _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
695             break;
696         case 2:         /* type */
697             _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
698             break;
699         case 3:         /* date */
700             _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
701             break;
702         case 4:         /* attributes */
703             _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
704             break;
705         }
706         hr = S_OK;
707         psd->str.uType = STRRET_CSTR;
708     }
709
710     return hr;
711 }
712 static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
713 {
714     IGenericSFImpl *This = (IGenericSFImpl *)iface;
715     FIXME ("(%p)\n", This);
716     return E_NOTIMPL;
717 }
718
719 static IShellFolder2Vtbl vt_MCFldr_ShellFolder2 =
720 {
721         ISF_Desktop_fnQueryInterface,
722         ISF_Desktop_fnAddRef,
723         ISF_Desktop_fnRelease,
724         ISF_Desktop_fnParseDisplayName,
725         ISF_Desktop_fnEnumObjects,
726         ISF_Desktop_fnBindToObject,
727         ISF_Desktop_fnBindToStorage,
728         ISF_Desktop_fnCompareIDs,
729         ISF_Desktop_fnCreateViewObject,
730         ISF_Desktop_fnGetAttributesOf,
731         ISF_Desktop_fnGetUIObjectOf,
732         ISF_Desktop_fnGetDisplayNameOf,
733         ISF_Desktop_fnSetNameOf,
734         /* ShellFolder2 */
735         ISF_Desktop_fnGetDefaultSearchGUID,
736         ISF_Desktop_fnEnumSearches,
737         ISF_Desktop_fnGetDefaultColumn,
738         ISF_Desktop_fnGetDefaultColumnState,
739         ISF_Desktop_fnGetDetailsEx,
740         ISF_Desktop_fnGetDetailsOf,
741         ISF_Desktop_fnMapColumnToSCID};