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