Added sprintfW and vsprintfW.
[wine] / dlls / shell32 / shfldr_mycomp.c
1
2 /*
3  *      Virtual Workplace 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 "pidl.h"
37 #include "shlguid.h"
38
39 #include "undocshell.h"
40 #include "shell32_main.h"
41 #include "shresdef.h"
42 #include "shlwapi.h"
43 #include "shellfolder.h"
44 #include "wine/debug.h"
45 #include "debughlp.h"
46 #include "shfldr.h"
47
48 WINE_DEFAULT_DEBUG_CHANNEL (shell);
49
50 /***********************************************************************
51 *   IShellFolder implementation
52 */
53
54 typedef struct {
55     ICOM_VFIELD (IShellFolder2);
56     DWORD ref;
57       ICOM_VTABLE (IPersistFolder2) * lpVtblPersistFolder2;
58
59     /* both paths are parsible from the desktop */
60     LPITEMIDLIST pidlRoot;      /* absolute pidl */
61     int dwAttributes;           /* attributes returned by GetAttributesOf FIXME: use it */
62 } IGenericSFImpl;
63
64 static struct ICOM_VTABLE (IShellFolder2) vt_ShellFolder2;
65 static struct ICOM_VTABLE (IPersistFolder2) vt_PersistFolder2;
66
67 HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
68
69 #define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2)))
70 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
71
72 /*
73   converts This to a interface pointer
74 */
75 #define _IUnknown_(This)        (IUnknown*)&(This->lpVtbl)
76 #define _IShellFolder_(This)    (IShellFolder*)&(This->lpVtbl)
77 #define _IShellFolder2_(This)   (IShellFolder2*)&(This->lpVtbl)
78
79 #define _IPersist_(This)        (IPersist*)&(This->lpVtblPersistFolder2)
80 #define _IPersistFolder_(This)  (IPersistFolder*)&(This->lpVtblPersistFolder2)
81 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
82
83 /***********************************************************************
84 *   IShellFolder [MyComputer] implementation
85 */
86
87 static shvheader MyComputerSFHeader[] = {
88     {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
89     {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
90     {IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
91     {IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
92 };
93
94 #define MYCOMPUTERSHELLVIEWCOLUMNS 4
95
96 /**************************************************************************
97 *       ISF_MyComputer_Constructor
98 */
99 HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
100 {
101     IGenericSFImpl *sf;
102
103     TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
104
105     if (!ppv)
106         return E_POINTER;
107     if (pUnkOuter)
108         return CLASS_E_NOAGGREGATION;
109
110     sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
111     if (!sf)
112         return E_OUTOFMEMORY;
113
114     sf->ref = 0;
115     ICOM_VTBL (sf) = &vt_ShellFolder2;
116     sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
117     sf->pidlRoot = _ILCreateMyComputer ();      /* my qualified pidl */
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_MyComputer_fnQueryInterface
130  *
131  * NOTES supports not IPersist/IPersistFolder
132  */
133 static HRESULT WINAPI ISF_MyComputer_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) ||
142         IsEqualIID (riid, &IID_IShellFolder) || IsEqualIID (riid, &IID_IShellFolder2)) {
143         *ppvObj = This;
144     } else if (IsEqualIID (riid, &IID_IPersist) ||
145                IsEqualIID (riid, &IID_IPersistFolder) || IsEqualIID (riid, &IID_IPersistFolder2)) {
146         *ppvObj = _IPersistFolder2_ (This);
147     }
148
149     if (*ppvObj) {
150         IUnknown_AddRef ((IUnknown *) (*ppvObj));
151         TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
152         return S_OK;
153     }
154     TRACE ("-- Interface: E_NOINTERFACE\n");
155     return E_NOINTERFACE;
156 }
157
158 static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
159 {
160     ICOM_THIS (IGenericSFImpl, iface);
161
162     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
163
164     return ++(This->ref);
165 }
166
167 static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
168 {
169     ICOM_THIS (IGenericSFImpl, iface);
170
171     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
172
173     if (!--(This->ref)) {
174         TRACE ("-- destroying IShellFolder(%p)\n", This);
175         if (This->pidlRoot)
176             SHFree (This->pidlRoot);
177         LocalFree ((HLOCAL) This);
178         return 0;
179     }
180     return This->ref;
181 }
182
183 /**************************************************************************
184 *       ISF_MyComputer_fnParseDisplayName
185 */
186 static HRESULT WINAPI
187 ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
188                                    HWND hwndOwner,
189                                    LPBC pbcReserved,
190                                    LPOLESTR lpszDisplayName,
191                                    DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
192 {
193     ICOM_THIS (IGenericSFImpl, iface);
194
195     HRESULT hr = E_OUTOFMEMORY;
196     LPCWSTR szNext = NULL;
197     WCHAR szElement[MAX_PATH];
198     CHAR szTempA[MAX_PATH];
199     LPITEMIDLIST pidlTemp;
200
201     TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
202            This, hwndOwner, pbcReserved, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
203
204     *ppidl = 0;
205     if (pchEaten)
206         *pchEaten = 0;          /* strange but like the original */
207
208     /* do we have an absolute path name ? */
209     if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
210         szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
211         WideCharToMultiByte (CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL);
212         pidlTemp = _ILCreateDrive (szTempA);
213
214         if (szNext && *szNext) {
215             hr = SHELL32_ParseNextElement (hwndOwner, iface, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
216         } else {
217             if (pdwAttributes && *pdwAttributes) {
218                 SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
219             }
220             hr = S_OK;
221         }
222         *ppidl = pidlTemp;
223     }
224
225     TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
226
227     return hr;
228 }
229
230 /**************************************************************************
231 *               ISF_MyComputer_fnEnumObjects
232 */
233 static HRESULT WINAPI
234 ISF_MyComputer_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
235 {
236     ICOM_THIS (IGenericSFImpl, iface);
237
238     TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
239
240     *ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_MYCOMP);
241
242     TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
243
244     return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
245 }
246
247 /**************************************************************************
248 *               ISF_MyComputer_fnBindToObject
249 */
250 static HRESULT WINAPI
251 ISF_MyComputer_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl,
252                                LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
253 {
254     ICOM_THIS (IGenericSFImpl, iface);
255
256     TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
257
258     return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
259 }
260
261 /**************************************************************************
262 *       ISF_MyComputer_fnBindToStorage
263 */
264 static HRESULT WINAPI
265 ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface,
266                                 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
267 {
268     ICOM_THIS (IGenericSFImpl, iface);
269
270     FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
271
272     *ppvOut = NULL;
273     return E_NOTIMPL;
274 }
275
276 /**************************************************************************
277 *       ISF_MyComputer_fnCompareIDs
278 */
279
280 static HRESULT WINAPI
281 ISF_MyComputer_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
282 {
283     ICOM_THIS (IGenericSFImpl, iface);
284
285     int nReturn;
286
287     TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
288     nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
289     TRACE ("-- %i\n", nReturn);
290     return nReturn;
291 }
292
293 /**************************************************************************
294 *       ISF_MyComputer_fnCreateViewObject
295 */
296 static HRESULT WINAPI
297 ISF_MyComputer_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
298 {
299     ICOM_THIS (IGenericSFImpl, iface);
300
301     LPSHELLVIEW pShellView;
302     HRESULT hr = E_INVALIDARG;
303
304     TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut);
305
306     if (ppvOut) {
307         *ppvOut = NULL;
308
309         if (IsEqualIID (riid, &IID_IDropTarget)) {
310             WARN ("IDropTarget not implemented\n");
311             hr = E_NOTIMPL;
312         } else if (IsEqualIID (riid, &IID_IContextMenu)) {
313             WARN ("IContextMenu not implemented\n");
314             hr = E_NOTIMPL;
315         } else if (IsEqualIID (riid, &IID_IShellView)) {
316             pShellView = IShellView_Constructor ((IShellFolder *) iface);
317             if (pShellView) {
318                 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
319                 IShellView_Release (pShellView);
320             }
321         }
322     }
323     TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
324     return hr;
325 }
326
327 /**************************************************************************
328 *  ISF_MyComputer_fnGetAttributesOf
329 */
330 static HRESULT WINAPI
331 ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
332 {
333     ICOM_THIS (IGenericSFImpl, iface);
334
335     HRESULT hr = S_OK;
336
337     TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
338
339     if ((!cidl) || (!apidl) || (!rgfInOut))
340         return E_INVALIDARG;
341
342     while (cidl > 0 && *apidl) {
343         pdump (*apidl);
344         SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
345         apidl++;
346         cidl--;
347     }
348
349     TRACE ("-- result=0x%08lx\n", *rgfInOut);
350     return hr;
351 }
352
353 /**************************************************************************
354 *       ISF_MyComputer_fnGetUIObjectOf
355 *
356 * PARAMETERS
357 *  HWND           hwndOwner, //[in ] Parent window for any output
358 *  UINT           cidl,      //[in ] array size
359 *  LPCITEMIDLIST* apidl,     //[in ] simple pidl array
360 *  REFIID         riid,      //[in ] Requested Interface
361 *  UINT*          prgfInOut, //[   ] reserved
362 *  LPVOID*        ppvObject) //[out] Resulting Interface
363 *
364 */
365 static HRESULT WINAPI
366 ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
367                                 HWND hwndOwner,
368                                 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
369 {
370     ICOM_THIS (IGenericSFImpl, iface);
371
372     LPITEMIDLIST pidl;
373     IUnknown *pObj = NULL;
374     HRESULT hr = E_INVALIDARG;
375
376     TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
377            This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
378
379     if (ppvOut) {
380         *ppvOut = NULL;
381
382         if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
383             pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
384             hr = S_OK;
385         } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
386             pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
387             hr = S_OK;
388         } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
389             pidl = ILCombine (This->pidlRoot, apidl[0]);
390             pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
391             SHFree (pidl);
392             hr = S_OK;
393         } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
394             pidl = ILCombine (This->pidlRoot, apidl[0]);
395             pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
396             SHFree (pidl);
397             hr = S_OK;
398         } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
399             hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
400         } else {
401             hr = E_NOINTERFACE;
402         }
403
404         if (!pObj)
405             hr = E_OUTOFMEMORY;
406
407         *ppvOut = pObj;
408     }
409     TRACE ("(%p)->hr=0x%08lx\n", This, hr);
410     return hr;
411 }
412
413 /**************************************************************************
414 *       ISF_MyComputer_fnGetDisplayNameOf
415 *
416 * NOTES
417 *       The desktopfolder creates only complete paths (SHGDN_FORPARSING).
418 *       SHGDN_INFOLDER makes no sense.
419 */
420 static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
421 {
422     ICOM_THIS (IGenericSFImpl, iface);
423
424     char szPath[MAX_PATH],
425       szDrive[18];
426     int len = 0;
427     BOOL bSimplePidl;
428
429     TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
430     pdump (pidl);
431
432     if (!strRet)
433         return E_INVALIDARG;
434
435     szPath[0] = 0x00;
436     szDrive[0] = 0x00;
437
438     bSimplePidl = _ILIsPidlSimple (pidl);
439
440     if (_ILIsSpecialFolder (pidl)) {
441         /* take names of special folders only if its only this folder */
442         if (bSimplePidl) {
443             _ILSimpleGetText (pidl, szPath, MAX_PATH);  /* append my own path */
444         } else {
445             FIXME ("special folder\n");
446         }
447     } else {
448         if (!_ILIsDrive (pidl)) {
449             ERR ("Wrong pidl type\n");
450             return E_INVALIDARG;
451         }
452
453         _ILSimpleGetText (pidl, szPath, MAX_PATH);      /* append my own path */
454
455         /* long view "lw_name (C:)" */
456         if (bSimplePidl && !(dwFlags & SHGDN_FORPARSING)) {
457             DWORD dwVolumeSerialNumber,
458               dwMaximumComponetLength,
459               dwFileSystemFlags;
460
461             GetVolumeInformationA (szPath, szDrive, sizeof (szDrive) - 6, &dwVolumeSerialNumber,
462                                    &dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0);
463             strcat (szDrive, " (");
464             strncat (szDrive, szPath, 2);
465             strcat (szDrive, ")");
466             strcpy (szPath, szDrive);
467         }
468     }
469
470     if (!bSimplePidl) {         /* go deeper if needed */
471         PathAddBackslashA (szPath);
472         len = strlen (szPath);
473
474         if (!SUCCEEDED
475             (SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len)))
476             return E_OUTOFMEMORY;
477     }
478     strRet->uType = STRRET_CSTR;
479     lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
480
481     TRACE ("-- (%p)->(%s)\n", This, szPath);
482     return S_OK;
483 }
484
485 /**************************************************************************
486 *  ISF_MyComputer_fnSetNameOf
487 *  Changes the name of a file object or subfolder, possibly changing its item
488 *  identifier in the process.
489 *
490 * PARAMETERS
491 *  HWND          hwndOwner,  //[in ] Owner window for output
492 *  LPCITEMIDLIST pidl,       //[in ] simple pidl of item to change
493 *  LPCOLESTR     lpszName,   //[in ] the items new display name
494 *  DWORD         dwFlags,    //[in ] SHGNO formatting flags
495 *  LPITEMIDLIST* ppidlOut)   //[out] simple pidl returned
496 */
497 static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,    /*simple pidl */
498                                                   LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
499 {
500     ICOM_THIS (IGenericSFImpl, iface);
501     FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
502     return E_FAIL;
503 }
504
505 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
506 {
507     ICOM_THIS (IGenericSFImpl, iface);
508     FIXME ("(%p)\n", This);
509     return E_NOTIMPL;
510 }
511 static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
512 {
513     ICOM_THIS (IGenericSFImpl, iface);
514     FIXME ("(%p)\n", This);
515     return E_NOTIMPL;
516 }
517 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
518 {
519     ICOM_THIS (IGenericSFImpl, iface);
520
521     TRACE ("(%p)\n", This);
522
523     if (pSort) *pSort = 0;
524     if (pDisplay) *pDisplay = 0;
525     return S_OK;
526 }
527 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
528 {
529     ICOM_THIS (IGenericSFImpl, iface);
530
531     TRACE ("(%p)\n", This);
532
533     if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) return E_INVALIDARG;
534     *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
535     return S_OK;
536 }
537 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
538 {
539     ICOM_THIS (IGenericSFImpl, iface);
540     FIXME ("(%p)\n", This);
541     return E_NOTIMPL;
542 }
543
544 /* FIXME: drive size >4GB is rolling over */
545 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
546 {
547     ICOM_THIS (IGenericSFImpl, iface);
548     HRESULT hr;
549
550     TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
551
552     if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
553         return E_INVALIDARG;
554
555     if (!pidl) {
556         psd->fmt = MyComputerSFHeader[iColumn].fmt;
557         psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
558         psd->str.uType = STRRET_CSTR;
559         LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
560         return S_OK;
561     } else {
562         char szPath[MAX_PATH];
563         ULARGE_INTEGER ulBytes;
564
565         psd->str.u.cStr[0] = 0x00;
566         psd->str.uType = STRRET_CSTR;
567         switch (iColumn) {
568         case 0:         /* name */
569             hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
570             break;
571         case 1:         /* type */
572             _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
573             break;
574         case 2:         /* total size */
575             if (_ILIsDrive (pidl)) {
576                 _ILSimpleGetText (pidl, szPath, MAX_PATH);
577                 GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL);
578                 StrFormatByteSizeA (ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
579             }
580             break;
581         case 3:         /* free size */
582             if (_ILIsDrive (pidl)) {
583                 _ILSimpleGetText (pidl, szPath, MAX_PATH);
584                 GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL);
585                 StrFormatByteSizeA (ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
586             }
587             break;
588         }
589         hr = S_OK;
590     }
591
592     return hr;
593 }
594 static HRESULT WINAPI ISF_MyComputer_fnMapNameToSCID (IShellFolder2 * iface, LPCWSTR pwszName, SHCOLUMNID * pscid)
595 {
596     ICOM_THIS (IGenericSFImpl, iface);
597     FIXME ("(%p)\n", This);
598     return E_NOTIMPL;
599 }
600
601 static ICOM_VTABLE (IShellFolder2) vt_ShellFolder2 =
602 {
603         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
604         ISF_MyComputer_fnQueryInterface,
605         ISF_MyComputer_fnAddRef,
606         ISF_MyComputer_fnRelease,
607         ISF_MyComputer_fnParseDisplayName,
608         ISF_MyComputer_fnEnumObjects,
609         ISF_MyComputer_fnBindToObject,
610         ISF_MyComputer_fnBindToStorage,
611         ISF_MyComputer_fnCompareIDs,
612         ISF_MyComputer_fnCreateViewObject,
613         ISF_MyComputer_fnGetAttributesOf,
614         ISF_MyComputer_fnGetUIObjectOf,
615         ISF_MyComputer_fnGetDisplayNameOf,
616         ISF_MyComputer_fnSetNameOf,
617         /* ShellFolder2 */
618         ISF_MyComputer_fnGetDefaultSearchGUID,
619         ISF_MyComputer_fnEnumSearches,
620         ISF_MyComputer_fnGetDefaultColumn,
621         ISF_MyComputer_fnGetDefaultColumnState,
622         ISF_MyComputer_fnGetDetailsEx,
623         ISF_MyComputer_fnGetDetailsOf,
624         ISF_MyComputer_fnMapNameToSCID
625 };
626
627 /************************************************************************
628  *      IMCFldr_PersistFolder2_QueryInterface
629  */
630 static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj)
631 {
632     _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
633
634     TRACE ("(%p)\n", This);
635
636     return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj);
637 }
638
639 /************************************************************************
640  *      IMCFldr_PersistFolder2_AddRef
641  */
642 static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
643 {
644     _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
645
646     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
647
648     return IUnknown_AddRef (_IUnknown_ (This));
649 }
650
651 /************************************************************************
652  *      ISFPersistFolder_Release
653  */
654 static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface)
655 {
656     _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
657
658     TRACE ("(%p)->(count=%lu)\n", This, This->ref);
659
660     return IUnknown_Release (_IUnknown_ (This));
661 }
662
663 /************************************************************************
664  *      IMCFldr_PersistFolder2_GetClassID
665  */
666 static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (IPersistFolder2 * iface, CLSID * lpClassId)
667 {
668     _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
669
670     TRACE ("(%p)\n", This);
671
672     if (!lpClassId)
673         return E_POINTER;
674     *lpClassId = CLSID_MyComputer;
675
676     return S_OK;
677 }
678
679 /************************************************************************
680  *      IMCFldr_PersistFolder2_Initialize
681  *
682  * NOTES: it makes no sense to change the pidl
683  */
684 static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl)
685 {
686     _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
687     TRACE ("(%p)->(%p)\n", This, pidl);
688     return E_NOTIMPL;
689 }
690
691 /**************************************************************************
692  *      IPersistFolder2_fnGetCurFolder
693  */
694 static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (IPersistFolder2 * iface, LPITEMIDLIST * pidl)
695 {
696     _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
697
698     TRACE ("(%p)->(%p)\n", This, pidl);
699
700     if (!pidl)
701         return E_POINTER;
702     *pidl = ILClone (This->pidlRoot);
703     return S_OK;
704 }
705
706 static ICOM_VTABLE (IPersistFolder2) vt_PersistFolder2 =
707 {
708 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
709         IMCFldr_PersistFolder2_QueryInterface,
710         IMCFldr_PersistFolder2_AddRef,
711         IMCFldr_PersistFolder2_Release,
712         IMCFldr_PersistFolder2_GetClassID,
713         IMCFldr_PersistFolder2_Initialize,
714         IMCFldr_PersistFolder2_GetCurFolder
715 };