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