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