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