Implemented shtypes.idl and shobjidl.idl and removed a few more
[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 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
32 #include "winerror.h"
33 #include "winbase.h"
34 #include "winreg.h"
35
36 #include "ole2.h"
37 #include "shlguid.h"
38
39 #include "pidl.h"
40 #include "undocshell.h"
41 #include "shell32_main.h"
42 #include "shresdef.h"
43 #include "shlwapi.h"
44 #include "shellfolder.h"
45 #include "wine/debug.h"
46 #include "debughlp.h"
47 #include "shfldr.h"
48
49 WINE_DEFAULT_DEBUG_CHANNEL (shell);
50
51 /***********************************************************************
52 *       Desktopfolder implementation
53 */
54
55 typedef struct {
56     ICOM_VFIELD (IShellFolder2);
57     DWORD ref;
58
59     CLSID *pclsid;
60
61     /* both paths are parsible from the desktop */
62     LPSTR sPathTarget;          /* complete path to target used for enumeration and ChangeNotify */
63     LPITEMIDLIST pidlRoot;      /* absolute pidl */
64
65     int dwAttributes;           /* attributes returned by GetAttributesOf FIXME: use it */
66
67     UINT cfShellIDList;         /* clipboardformat for IDropTarget */
68     BOOL fAcceptFmt;            /* flag for pending Drop */
69 } IGenericSFImpl;
70
71 #define _IUnknown_(This)        (IShellFolder*)&(This->lpVtbl)
72 #define _IShellFolder_(This)    (IShellFolder*)&(This->lpVtbl)
73
74 HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
75
76 static struct ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2;
77
78 static shvheader DesktopSFHeader[] = {
79     {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
80     {IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
81     {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
82     {IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12},
83     {IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5}
84 };
85
86 #define DESKTOPSHELLVIEWCOLUMNS 5
87
88 /**************************************************************************
89 *       ISF_Desktop_Constructor
90 */
91 HRESULT WINAPI ISF_Desktop_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
92 {
93     IGenericSFImpl *sf;
94     char szMyPath[MAX_PATH];
95
96     TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
97
98     if (!ppv)
99         return E_POINTER;
100     if (pUnkOuter)
101         return CLASS_E_NOAGGREGATION;
102
103     if (!SHGetSpecialFolderPathA (0, szMyPath, CSIDL_DESKTOPDIRECTORY, TRUE))
104         return E_UNEXPECTED;
105
106     sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
107     if (!sf)
108         return E_OUTOFMEMORY;
109
110     sf->ref = 0;
111     sf->lpVtbl = &vt_MCFldr_ShellFolder2;
112     sf->pidlRoot = _ILCreateDesktop (); /* my qualified pidl */
113     sf->sPathTarget = SHAlloc (strlen (szMyPath) + 1);
114     lstrcpyA (sf->sPathTarget, szMyPath);
115
116     if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
117         IUnknown_Release (_IUnknown_ (sf));
118         return E_NOINTERFACE;
119     }
120
121     TRACE ("--(%p)\n", sf);
122     return S_OK;
123 }
124
125 /**************************************************************************
126  *      ISF_Desktop_fnQueryInterface
127  *
128  * NOTES supports not IPersist/IPersistFolder
129  */
130 static HRESULT WINAPI ISF_Desktop_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
131 {
132     ICOM_THIS (IGenericSFImpl, iface);
133
134     TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
135
136     *ppvObj = NULL;
137
138     if (IsEqualIID (riid, &IID_IUnknown) || IsEqualIID (riid, &IID_IShellFolder)
139         || IsEqualIID (riid, &IID_IShellFolder2)) {
140         *ppvObj = This;
141     }
142
143     if (*ppvObj) {
144         IUnknown_AddRef ((IUnknown *) (*ppvObj));
145         TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
146         return S_OK;
147     }
148     TRACE ("-- Interface: E_NOINTERFACE\n");
149     return E_NOINTERFACE;
150 }
151
152 static ULONG WINAPI ISF_Desktop_fnAddRef (IShellFolder2 * iface)
153 {
154     ICOM_THIS (IGenericSFImpl, iface);
155
156     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
157
158     return ++(This->ref);
159 }
160
161 static ULONG WINAPI ISF_Desktop_fnRelease (IShellFolder2 * iface)
162 {
163     ICOM_THIS (IGenericSFImpl, iface);
164
165     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
166
167     if (!--(This->ref)) {
168         TRACE ("-- destroying IShellFolder(%p)\n", This);
169         if (This->pidlRoot)
170             SHFree (This->pidlRoot);
171         if (This->sPathTarget)
172             SHFree (This->sPathTarget);
173         LocalFree ((HLOCAL) This);
174         return 0;
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=%p,%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         SHCLSIDFromStringW (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=%p 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=%p,%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)->(%p,%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_IExtractIconW) && (cidl == 1)) {
414             pidl = ILCombine (This->pidlRoot, apidl[0]);
415             pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
416             SHFree (pidl);
417             hr = S_OK;
418         } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
419             hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
420         } else {
421             hr = E_NOINTERFACE;
422         }
423
424         if (!pObj)
425             hr = E_OUTOFMEMORY;
426
427         *ppvOut = pObj;
428     }
429     TRACE ("(%p)->hr=0x%08lx\n", This, hr);
430     return hr;
431 }
432
433 /**************************************************************************
434 *       ISF_Desktop_fnGetDisplayNameOf
435 *
436 * NOTES
437 *       special case: pidl = null gives desktop-name back
438 */
439 DWORD WINAPI __SHGUIDToStringA (REFGUID guid, LPSTR str)
440 {
441     CHAR sFormat[52] = "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
442
443     return wsprintfA (str, sFormat,
444                       guid->Data1, guid->Data2, guid->Data3,
445                       guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
446                       guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
447
448 }
449
450 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
451                                                       LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
452 {
453     ICOM_THIS (IGenericSFImpl, iface);
454
455     CHAR szPath[MAX_PATH] = "";
456     GUID const *clsid;
457     HRESULT hr = S_OK;
458
459     TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
460     pdump (pidl);
461
462     if (!strRet)
463         return E_INVALIDARG;
464
465     if (_ILIsDesktop (pidl)) {
466         if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) {
467             lstrcpyA (szPath, This->sPathTarget);
468         } else {
469             HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH);
470         }
471     } else if (_ILIsPidlSimple (pidl)) {
472         if ((clsid = _ILGetGUIDPointer (pidl))) {
473             if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
474                 int bWantsForParsing;
475
476                 /*
477                  * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
478                  * CLSID\\{...}\\shellfolder exists
479                  * exception: the MyComputer folder has this keys not but like any filesystem backed
480                  *            folder it needs these behaviour
481                  */
482                 if (IsEqualIID (clsid, &CLSID_MyComputer)) {
483                     bWantsForParsing = 1;
484                 } else {
485                     /* get the "WantsFORPARSING" flag from the registry */
486                     char szRegPath[100];
487
488                     lstrcpyA (szRegPath, "CLSID\\");
489                     __SHGUIDToStringA (clsid, &szRegPath[6]);
490                     lstrcatA (szRegPath, "\\shellfolder");
491                     bWantsForParsing =
492                         (ERROR_SUCCESS ==
493                          SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
494                 }
495
496                 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
497                     /* we need the filesystem path to the destination folder. Only the folder itself can know it */
498                     hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
499                 } else {
500                     /* parsing name like ::{...} */
501                     lstrcpyA (szPath, "::");
502                     __SHGUIDToStringA (clsid, &szPath[2]);
503                 }
504             } else {
505                 /* user friendly name */
506                 HCR_GetClassNameA (clsid, szPath, MAX_PATH);
507             }
508         } else {
509             /* file system folder */
510             _ILSimpleGetText (pidl, szPath, MAX_PATH);
511         }
512     } else {
513         /* a complex pidl, let the subfolder do the work */
514         hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
515     }
516
517     if (SUCCEEDED (hr)) {
518         strRet->uType = STRRET_CSTR;
519         lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
520     }
521
522     TRACE ("-- (%p)->(%s,0x%08lx)\n", This, szPath, hr);
523     return hr;
524 }
525
526 /**************************************************************************
527 *  ISF_Desktop_fnSetNameOf
528 *  Changes the name of a file object or subfolder, possibly changing its item
529 *  identifier in the process.
530 *
531 * PARAMETERS
532 *  HWND          hwndOwner,  //[in ] Owner window for output
533 *  LPCITEMIDLIST pidl,       //[in ] simple pidl of item to change
534 *  LPCOLESTR     lpszName,   //[in ] the items new display name
535 *  DWORD         dwFlags,    //[in ] SHGNO formatting flags
536 *  LPITEMIDLIST* ppidlOut)   //[out] simple pidl returned
537 */
538 static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,       /*simple pidl */
539                                                LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
540 {
541     ICOM_THIS (IGenericSFImpl, iface);
542
543     FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
544
545     return E_FAIL;
546 }
547
548 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
549 {
550     ICOM_THIS (IGenericSFImpl, iface);
551
552     FIXME ("(%p)\n", This);
553     return E_NOTIMPL;
554 }
555 static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
556 {
557     ICOM_THIS (IGenericSFImpl, iface);
558     FIXME ("(%p)\n", This);
559     return E_NOTIMPL;
560 }
561 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
562                                                       DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
563 {
564     ICOM_THIS (IGenericSFImpl, iface);
565
566     TRACE ("(%p)\n", This);
567
568     if (pSort)
569         *pSort = 0;
570     if (pDisplay)
571         *pDisplay = 0;
572
573     return S_OK;
574 }
575 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
576 {
577     ICOM_THIS (IGenericSFImpl, iface);
578
579     TRACE ("(%p)\n", This);
580
581     if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
582         return E_INVALIDARG;
583
584     *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
585
586     return S_OK;
587 }
588 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
589                                                   LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
590 {
591     ICOM_THIS (IGenericSFImpl, iface);
592     FIXME ("(%p)\n", This);
593
594     return E_NOTIMPL;
595 }
596 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
597                                                   LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
598 {
599     ICOM_THIS (IGenericSFImpl, iface);
600
601     HRESULT hr = E_FAIL;
602
603     TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
604
605     if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
606         return E_INVALIDARG;
607
608     if (!pidl) {
609         psd->fmt = DesktopSFHeader[iColumn].fmt;
610         psd->cxChar = DesktopSFHeader[iColumn].cxChar;
611         psd->str.uType = STRRET_CSTR;
612         LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
613         return S_OK;
614     } else {
615         /* the data from the pidl */
616         switch (iColumn) {
617         case 0:         /* name */
618             hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
619             break;
620         case 1:         /* size */
621             _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
622             break;
623         case 2:         /* type */
624             _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
625             break;
626         case 3:         /* date */
627             _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
628             break;
629         case 4:         /* attributes */
630             _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
631             break;
632         }
633         hr = S_OK;
634         psd->str.uType = STRRET_CSTR;
635     }
636
637     return hr;
638 }
639 static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
640 {
641     ICOM_THIS (IGenericSFImpl, iface);
642     FIXME ("(%p)\n", This);
643     return E_NOTIMPL;
644 }
645
646 static ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2 =
647 {
648         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
649         ISF_Desktop_fnQueryInterface,
650         ISF_Desktop_fnAddRef,
651         ISF_Desktop_fnRelease,
652         ISF_Desktop_fnParseDisplayName,
653         ISF_Desktop_fnEnumObjects,
654         ISF_Desktop_fnBindToObject,
655         ISF_Desktop_fnBindToStorage,
656         ISF_Desktop_fnCompareIDs,
657         ISF_Desktop_fnCreateViewObject,
658         ISF_Desktop_fnGetAttributesOf,
659         ISF_Desktop_fnGetUIObjectOf,
660         ISF_Desktop_fnGetDisplayNameOf,
661         ISF_Desktop_fnSetNameOf,
662         /* ShellFolder2 */
663         ISF_Desktop_fnGetDefaultSearchGUID,
664         ISF_Desktop_fnEnumSearches,
665         ISF_Desktop_fnGetDefaultColumn,
666         ISF_Desktop_fnGetDefaultColumnState,
667         ISF_Desktop_fnGetDetailsEx,
668         ISF_Desktop_fnGetDetailsOf,
669         ISF_Desktop_fnMapColumnToSCID};