Tests for recent variant changes.
[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 = lpszDisplayName;
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 DWORD WINAPI __SHGUIDToStringA (REFGUID guid, LPSTR str)
453 {
454     CHAR sFormat[52] = "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}";
455
456     return wsprintfA (str, sFormat,
457                       guid->Data1, guid->Data2, guid->Data3,
458                       guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
459                       guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
460
461 }
462
463 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf (IShellFolder2 * iface,
464                                                       LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
465 {
466     ICOM_THIS (IGenericSFImpl, iface);
467
468     CHAR szPath[MAX_PATH] = "";
469     GUID const *clsid;
470     HRESULT hr = S_OK;
471
472     TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
473     pdump (pidl);
474
475     if (!strRet)
476         return E_INVALIDARG;
477
478     if (_ILIsDesktop (pidl)) {
479         if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING)) {
480             lstrcpyA (szPath, This->sPathTarget);
481         } else {
482             HCR_GetClassNameA(&CLSID_ShellDesktop, szPath, MAX_PATH);
483         }
484     } else if (_ILIsPidlSimple (pidl)) {
485         if ((clsid = _ILGetGUIDPointer (pidl))) {
486             if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
487                 int bWantsForParsing;
488
489                 /*
490                  * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
491                  * CLSID\\{...}\\shellfolder exists
492                  * exception: the MyComputer folder has this keys not but like any filesystem backed
493                  *            folder it needs these behaviour
494                  */
495                 if (IsEqualIID (clsid, &CLSID_MyComputer)) {
496                     bWantsForParsing = 1;
497                 } else {
498                     /* get the "WantsFORPARSING" flag from the registry */
499                     char szRegPath[100];
500
501                     lstrcpyA (szRegPath, "CLSID\\");
502                     __SHGUIDToStringA (clsid, &szRegPath[6]);
503                     lstrcatA (szRegPath, "\\shellfolder");
504                     bWantsForParsing =
505                         (ERROR_SUCCESS ==
506                          SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
507                 }
508
509                 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
510                     /* we need the filesystem path to the destination folder. Only the folder itself can know it */
511                     hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
512                 } else {
513                     /* parsing name like ::{...} */
514                     lstrcpyA (szPath, "::");
515                     __SHGUIDToStringA (clsid, &szPath[2]);
516                 }
517             } else {
518                 /* user friendly name */
519                 HCR_GetClassNameA (clsid, szPath, MAX_PATH);
520             }
521         } else {
522             /* file system folder */
523             _ILSimpleGetText (pidl, szPath, MAX_PATH);
524         }
525     } else {
526         /* a complex pidl, let the subfolder do the work */
527         hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
528     }
529
530     if (SUCCEEDED (hr)) {
531         strRet->uType = STRRET_CSTR;
532         lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
533     }
534
535     TRACE ("-- (%p)->(%s,0x%08lx)\n", This, szPath, hr);
536     return hr;
537 }
538
539 /**************************************************************************
540 *  ISF_Desktop_fnSetNameOf
541 *  Changes the name of a file object or subfolder, possibly changing its item
542 *  identifier in the process.
543 *
544 * PARAMETERS
545 *  HWND          hwndOwner,  //[in ] Owner window for output
546 *  LPCITEMIDLIST pidl,       //[in ] simple pidl of item to change
547 *  LPCOLESTR     lpszName,   //[in ] the items new display name
548 *  DWORD         dwFlags,    //[in ] SHGNO formatting flags
549 *  LPITEMIDLIST* ppidlOut)   //[out] simple pidl returned
550 */
551 static HRESULT WINAPI ISF_Desktop_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,       /*simple pidl */
552                                                LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
553 {
554     ICOM_THIS (IGenericSFImpl, iface);
555
556     FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
557
558     return E_FAIL;
559 }
560
561 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
562 {
563     ICOM_THIS (IGenericSFImpl, iface);
564
565     FIXME ("(%p)\n", This);
566     return E_NOTIMPL;
567 }
568 static HRESULT WINAPI ISF_Desktop_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
569 {
570     ICOM_THIS (IGenericSFImpl, iface);
571     FIXME ("(%p)\n", This);
572     return E_NOTIMPL;
573 }
574 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn (IShellFolder2 * iface,
575                                                       DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
576 {
577     ICOM_THIS (IGenericSFImpl, iface);
578
579     TRACE ("(%p)\n", This);
580
581     if (pSort)
582         *pSort = 0;
583     if (pDisplay)
584         *pDisplay = 0;
585
586     return S_OK;
587 }
588 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
589 {
590     ICOM_THIS (IGenericSFImpl, iface);
591
592     TRACE ("(%p)\n", This);
593
594     if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
595         return E_INVALIDARG;
596
597     *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
598
599     return S_OK;
600 }
601 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx (IShellFolder2 * iface,
602                                                   LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
603 {
604     ICOM_THIS (IGenericSFImpl, iface);
605     FIXME ("(%p)\n", This);
606
607     return E_NOTIMPL;
608 }
609 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf (IShellFolder2 * iface,
610                                                   LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
611 {
612     ICOM_THIS (IGenericSFImpl, iface);
613
614     HRESULT hr = E_FAIL;
615
616     TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
617
618     if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS)
619         return E_INVALIDARG;
620
621     if (!pidl) {
622         psd->fmt = DesktopSFHeader[iColumn].fmt;
623         psd->cxChar = DesktopSFHeader[iColumn].cxChar;
624         psd->str.uType = STRRET_CSTR;
625         LoadStringA (shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
626         return S_OK;
627     } else {
628         /* the data from the pidl */
629         switch (iColumn) {
630         case 0:         /* name */
631             hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
632             break;
633         case 1:         /* size */
634             _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
635             break;
636         case 2:         /* type */
637             _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
638             break;
639         case 3:         /* date */
640             _ILGetFileDate (pidl, psd->str.u.cStr, MAX_PATH);
641             break;
642         case 4:         /* attributes */
643             _ILGetFileAttributes (pidl, psd->str.u.cStr, MAX_PATH);
644             break;
645         }
646         hr = S_OK;
647         psd->str.uType = STRRET_CSTR;
648     }
649
650     return hr;
651 }
652 static HRESULT WINAPI ISF_Desktop_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
653 {
654     ICOM_THIS (IGenericSFImpl, iface);
655     FIXME ("(%p)\n", This);
656     return E_NOTIMPL;
657 }
658
659 static ICOM_VTABLE (IShellFolder2) vt_MCFldr_ShellFolder2 =
660 {
661         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
662         ISF_Desktop_fnQueryInterface,
663         ISF_Desktop_fnAddRef,
664         ISF_Desktop_fnRelease,
665         ISF_Desktop_fnParseDisplayName,
666         ISF_Desktop_fnEnumObjects,
667         ISF_Desktop_fnBindToObject,
668         ISF_Desktop_fnBindToStorage,
669         ISF_Desktop_fnCompareIDs,
670         ISF_Desktop_fnCreateViewObject,
671         ISF_Desktop_fnGetAttributesOf,
672         ISF_Desktop_fnGetUIObjectOf,
673         ISF_Desktop_fnGetDisplayNameOf,
674         ISF_Desktop_fnSetNameOf,
675         /* ShellFolder2 */
676         ISF_Desktop_fnGetDefaultSearchGUID,
677         ISF_Desktop_fnEnumSearches,
678         ISF_Desktop_fnGetDefaultColumn,
679         ISF_Desktop_fnGetDefaultColumnState,
680         ISF_Desktop_fnGetDetailsEx,
681         ISF_Desktop_fnGetDetailsOf,
682         ISF_Desktop_fnMapColumnToSCID};