Better EXE version check in VERSION_GetLinkedDllVersion.
[wine/gsoc_dplay.git] / dlls / shell32 / shfldr_mycomp.c
blob5de8574efcd2bcc527d4b09a51c13f51385868e2
2 /*
3 * Virtual Workplace folder
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998, 1999, 2002 Juergen Schmied
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.
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.
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
23 #include "config.h"
24 #include "wine/port.h"
26 #include <stdlib.h>
27 #include <string.h>
28 #include <stdarg.h>
29 #include <stdio.h>
31 #define COBJMACROS
32 #define NONAMELESSUNION
33 #define NONAMELESSSTRUCT
35 #include "winerror.h"
36 #include "windef.h"
37 #include "winbase.h"
38 #include "winreg.h"
40 #include "wingdi.h"
41 #include "pidl.h"
42 #include "shlguid.h"
43 #include "enumidlist.h"
44 #include "undocshell.h"
45 #include "shell32_main.h"
46 #include "shresdef.h"
47 #include "shlwapi.h"
48 #include "wine/debug.h"
49 #include "debughlp.h"
50 #include "shfldr.h"
52 WINE_DEFAULT_DEBUG_CHANNEL (shell);
54 /***********************************************************************
55 * IShellFolder implementation
58 typedef struct {
59 IShellFolder2Vtbl *lpVtbl;
60 DWORD ref;
61 IPersistFolder2Vtbl *lpVtblPersistFolder2;
63 /* both paths are parsible from the desktop */
64 LPITEMIDLIST pidlRoot; /* absolute pidl */
65 int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
66 } IGenericSFImpl;
68 static struct IShellFolder2Vtbl vt_ShellFolder2;
69 static struct IPersistFolder2Vtbl vt_PersistFolder2;
71 #define _IPersistFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpVtblPersistFolder2)))
72 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
75 converts This to a interface pointer
77 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
78 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
79 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl)
81 #define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2)
82 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2)
83 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
85 /***********************************************************************
86 * IShellFolder [MyComputer] implementation
89 static shvheader MyComputerSFHeader[] = {
90 {IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},
91 {IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
92 {IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
93 {IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10},
96 #define MYCOMPUTERSHELLVIEWCOLUMNS 4
98 /**************************************************************************
99 * ISF_MyComputer_Constructor
101 HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
103 IGenericSFImpl *sf;
105 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
107 if (!ppv)
108 return E_POINTER;
109 if (pUnkOuter)
110 return CLASS_E_NOAGGREGATION;
112 sf = (IGenericSFImpl *) LocalAlloc (GMEM_ZEROINIT, sizeof (IGenericSFImpl));
113 if (!sf)
114 return E_OUTOFMEMORY;
116 sf->ref = 0;
117 sf->lpVtbl = &vt_ShellFolder2;
118 sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
119 sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */
121 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (sf), riid, ppv))) {
122 IUnknown_Release (_IUnknown_ (sf));
123 return E_NOINTERFACE;
126 TRACE ("--(%p)\n", sf);
127 return S_OK;
130 /**************************************************************************
131 * ISF_MyComputer_fnQueryInterface
133 * NOTES supports not IPersist/IPersistFolder
135 static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 * iface, REFIID riid, LPVOID * ppvObj)
137 IGenericSFImpl *This = (IGenericSFImpl *)iface;
139 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
141 *ppvObj = NULL;
143 if (IsEqualIID (riid, &IID_IUnknown) ||
144 IsEqualIID (riid, &IID_IShellFolder) || IsEqualIID (riid, &IID_IShellFolder2)) {
145 *ppvObj = This;
146 } else if (IsEqualIID (riid, &IID_IPersist) ||
147 IsEqualIID (riid, &IID_IPersistFolder) || IsEqualIID (riid, &IID_IPersistFolder2)) {
148 *ppvObj = _IPersistFolder2_ (This);
151 if (*ppvObj) {
152 IUnknown_AddRef ((IUnknown *) (*ppvObj));
153 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
154 return S_OK;
156 TRACE ("-- Interface: E_NOINTERFACE\n");
157 return E_NOINTERFACE;
160 static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
162 IGenericSFImpl *This = (IGenericSFImpl *)iface;
164 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
166 return ++(This->ref);
169 static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
171 IGenericSFImpl *This = (IGenericSFImpl *)iface;
173 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
175 if (!--(This->ref)) {
176 TRACE ("-- destroying IShellFolder(%p)\n", This);
177 if (This->pidlRoot)
178 SHFree (This->pidlRoot);
179 LocalFree ((HLOCAL) This);
180 return 0;
182 return This->ref;
185 /**************************************************************************
186 * ISF_MyComputer_fnParseDisplayName
188 static HRESULT WINAPI
189 ISF_MyComputer_fnParseDisplayName (IShellFolder2 * iface,
190 HWND hwndOwner,
191 LPBC pbc,
192 LPOLESTR lpszDisplayName,
193 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
195 IGenericSFImpl *This = (IGenericSFImpl *)iface;
197 HRESULT hr = E_INVALIDARG;
198 LPCWSTR szNext = NULL;
199 WCHAR szElement[MAX_PATH];
200 LPITEMIDLIST pidlTemp = NULL;
201 CLSID clsid;
203 TRACE ("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
204 This, hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName), pchEaten, ppidl, pdwAttributes);
206 *ppidl = 0;
207 if (pchEaten)
208 *pchEaten = 0; /* strange but like the original */
210 /* handle CLSID paths */
211 if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':') {
212 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
213 TRACE ("-- element: %s\n", debugstr_w (szElement));
214 SHCLSIDFromStringW (szElement + 2, &clsid);
215 pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
217 /* do we have an absolute path name ? */
218 else if (PathGetDriveNumberW (lpszDisplayName) >= 0 && lpszDisplayName[2] == (WCHAR) '\\') {
219 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
220 szElement[0] = toupper(szElement[0]); /* make drive letter uppercase to enable PIDL comparison */
221 pidlTemp = _ILCreateDrive (szElement);
224 if (szNext && *szNext) {
225 hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
226 } else {
227 if (pdwAttributes && *pdwAttributes) {
228 SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
230 hr = S_OK;
233 *ppidl = pidlTemp;
235 TRACE ("(%p)->(-- ret=0x%08lx)\n", This, hr);
237 return hr;
240 /**************************************************************************
241 * CreateMyCompEnumList()
243 static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags)
245 BOOL ret = TRUE;
247 TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags);
249 /*enumerate the folders*/
250 if(dwFlags & SHCONTF_FOLDERS)
252 WCHAR wszDriveName[] = {'A', ':', '\\', '\0'};
253 DWORD dwDrivemap = GetLogicalDrives();
254 HKEY hkey;
256 while (ret && wszDriveName[0]<='Z')
258 if(dwDrivemap & 0x00000001L)
259 ret = AddToEnumList(list, _ILCreateDrive(wszDriveName));
260 wszDriveName[0]++;
261 dwDrivemap = dwDrivemap >> 1;
264 TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list);
265 if (ret && !RegOpenKeyExA(HKEY_LOCAL_MACHINE,
266 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\explorer\\mycomputer\\NameSpace",
267 0, KEY_READ, &hkey))
269 char iid[50];
270 int i=0;
272 while (ret)
274 DWORD size = sizeof (iid);
275 LONG apiRet = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL,
276 NULL);
278 if (ERROR_SUCCESS == apiRet)
280 /* FIXME: shell extensions, shouldn't the type be
281 * PT_SHELLEXT? */
282 ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid));
283 i++;
285 else if (ERROR_NO_MORE_ITEMS == apiRet)
286 break;
287 else
288 ret = FALSE;
290 RegCloseKey(hkey);
293 return ret;
296 /**************************************************************************
297 * ISF_MyComputer_fnEnumObjects
299 static HRESULT WINAPI
300 ISF_MyComputer_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
302 IGenericSFImpl *This = (IGenericSFImpl *)iface;
304 TRACE ("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
306 *ppEnumIDList = IEnumIDList_Constructor();
307 if (*ppEnumIDList)
308 CreateMyCompEnumList(*ppEnumIDList, dwFlags);
310 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
312 return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
315 /**************************************************************************
316 * ISF_MyComputer_fnBindToObject
318 static HRESULT WINAPI
319 ISF_MyComputer_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl,
320 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
322 IGenericSFImpl *This = (IGenericSFImpl *)iface;
324 TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
326 return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
329 /**************************************************************************
330 * ISF_MyComputer_fnBindToStorage
332 static HRESULT WINAPI
333 ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface,
334 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
336 IGenericSFImpl *This = (IGenericSFImpl *)iface;
338 FIXME ("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
340 *ppvOut = NULL;
341 return E_NOTIMPL;
344 /**************************************************************************
345 * ISF_MyComputer_fnCompareIDs
348 static HRESULT WINAPI
349 ISF_MyComputer_fnCompareIDs (IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
351 IGenericSFImpl *This = (IGenericSFImpl *)iface;
353 int nReturn;
355 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
356 nReturn = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
357 TRACE ("-- %i\n", nReturn);
358 return nReturn;
361 /**************************************************************************
362 * ISF_MyComputer_fnCreateViewObject
364 static HRESULT WINAPI
365 ISF_MyComputer_fnCreateViewObject (IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
367 IGenericSFImpl *This = (IGenericSFImpl *)iface;
369 LPSHELLVIEW pShellView;
370 HRESULT hr = E_INVALIDARG;
372 TRACE ("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid (riid), ppvOut);
374 if (ppvOut) {
375 *ppvOut = NULL;
377 if (IsEqualIID (riid, &IID_IDropTarget)) {
378 WARN ("IDropTarget not implemented\n");
379 hr = E_NOTIMPL;
380 } else if (IsEqualIID (riid, &IID_IContextMenu)) {
381 WARN ("IContextMenu not implemented\n");
382 hr = E_NOTIMPL;
383 } else if (IsEqualIID (riid, &IID_IShellView)) {
384 pShellView = IShellView_Constructor ((IShellFolder *) iface);
385 if (pShellView) {
386 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
387 IShellView_Release (pShellView);
391 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
392 return hr;
395 /**************************************************************************
396 * ISF_MyComputer_fnGetAttributesOf
398 static HRESULT WINAPI
399 ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
401 IGenericSFImpl *This = (IGenericSFImpl *)iface;
403 HRESULT hr = S_OK;
405 TRACE ("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
407 if ((!cidl) || (!apidl) || (!rgfInOut))
408 return E_INVALIDARG;
410 if (*rgfInOut == 0)
411 *rgfInOut = ~0;
413 while (cidl > 0 && *apidl) {
414 pdump (*apidl);
415 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
416 apidl++;
417 cidl--;
420 TRACE ("-- result=0x%08lx\n", *rgfInOut);
421 return hr;
424 /**************************************************************************
425 * ISF_MyComputer_fnGetUIObjectOf
427 * PARAMETERS
428 * HWND hwndOwner, //[in ] Parent window for any output
429 * UINT cidl, //[in ] array size
430 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
431 * REFIID riid, //[in ] Requested Interface
432 * UINT* prgfInOut, //[ ] reserved
433 * LPVOID* ppvObject) //[out] Resulting Interface
436 static HRESULT WINAPI
437 ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
438 HWND hwndOwner,
439 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
441 IGenericSFImpl *This = (IGenericSFImpl *)iface;
443 LPITEMIDLIST pidl;
444 IUnknown *pObj = NULL;
445 HRESULT hr = E_INVALIDARG;
447 TRACE ("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
448 This, hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
450 if (ppvOut) {
451 *ppvOut = NULL;
453 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1)) {
454 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
455 hr = S_OK;
456 } else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1)) {
457 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner, This->pidlRoot, apidl, cidl);
458 hr = S_OK;
459 } else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1)) {
460 pidl = ILCombine (This->pidlRoot, apidl[0]);
461 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
462 SHFree (pidl);
463 hr = S_OK;
464 } else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1)) {
465 pidl = ILCombine (This->pidlRoot, apidl[0]);
466 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
467 SHFree (pidl);
468 hr = S_OK;
469 } else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1)) {
470 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget, (LPVOID *) & pObj);
471 } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
472 && (cidl == 1)) {
473 pidl = ILCombine (This->pidlRoot, apidl[0]);
474 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*)&pObj);
475 SHFree (pidl);
476 } else {
477 hr = E_NOINTERFACE;
480 if (SUCCEEDED(hr) && !pObj)
481 hr = E_OUTOFMEMORY;
483 *ppvOut = pObj;
485 TRACE ("(%p)->hr=0x%08lx\n", This, hr);
486 return hr;
489 /**************************************************************************
490 * ISF_MyComputer_fnGetDisplayNameOf
492 static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
494 IGenericSFImpl *This = (IGenericSFImpl *)iface;
496 char szPath[MAX_PATH],
497 szDrive[18];
498 int len = 0;
499 BOOL bSimplePidl;
500 HRESULT hr = S_OK;
502 TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
503 pdump (pidl);
505 if (!strRet)
506 return E_INVALIDARG;
508 szPath[0] = 0x00;
509 szDrive[0] = 0x00;
511 bSimplePidl = _ILIsPidlSimple (pidl);
513 if (!pidl->mkid.cb) {
514 /* parsing name like ::{...} */
515 lstrcpyA (szPath, "::");
516 SHELL32_GUIDToStringA(&CLSID_MyComputer, &szPath[2]);
517 } else if (_ILIsSpecialFolder (pidl)) {
518 /* take names of special folders only if its only this folder */
519 if (bSimplePidl) {
520 GUID const *clsid;
522 if ((clsid = _ILGetGUIDPointer (pidl))) {
523 if (GET_SHGDN_FOR (dwFlags) == SHGDN_FORPARSING) {
524 int bWantsForParsing;
527 * we can only get a filesystem path from a shellfolder if the value WantsFORPARSING in
528 * CLSID\\{...}\\shellfolder exists
529 * exception: the MyComputer folder has this keys not but like any filesystem backed
530 * folder it needs these behaviour
532 /* get the "WantsFORPARSING" flag from the registry */
533 char szRegPath[100];
535 lstrcpyA (szRegPath, "CLSID\\");
536 SHELL32_GUIDToStringA (clsid, &szRegPath[6]);
537 lstrcatA (szRegPath, "\\shellfolder");
538 bWantsForParsing =
539 (ERROR_SUCCESS ==
540 SHGetValueA (HKEY_CLASSES_ROOT, szRegPath, "WantsFORPARSING", NULL, NULL, NULL));
542 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) && bWantsForParsing) {
543 /* we need the filesystem path to the destination folder. Only the folder itself can know it */
544 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags, szPath, MAX_PATH);
545 } else {
546 LPSTR p;
548 /* parsing name like ::{...} */
549 p = lstrcpyA(szPath, "::") + 2;
550 p += SHELL32_GUIDToStringA(&CLSID_MyComputer, p);
552 lstrcatA(p, "\\::");
553 p += 3;
554 SHELL32_GUIDToStringA(clsid, p);
556 } else {
557 /* user friendly name */
558 HCR_GetClassNameA (clsid, szPath, MAX_PATH);
560 } else
561 _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
562 } else {
563 FIXME ("special folder\n");
565 } else {
566 if (!_ILIsDrive (pidl)) {
567 ERR ("Wrong pidl type\n");
568 return E_INVALIDARG;
571 _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */
573 /* long view "lw_name (C:)" */
574 if (bSimplePidl && !(dwFlags & SHGDN_FORPARSING)) {
575 DWORD dwVolumeSerialNumber,
576 dwMaximumComponetLength,
577 dwFileSystemFlags;
579 GetVolumeInformationA (szPath, szDrive, sizeof (szDrive) - 6, &dwVolumeSerialNumber,
580 &dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0);
581 strcat (szDrive, " (");
582 strncat (szDrive, szPath, 2);
583 strcat (szDrive, ")");
584 strcpy (szPath, szDrive);
588 if (!bSimplePidl) { /* go deeper if needed */
589 PathAddBackslashA (szPath);
590 len = strlen (szPath);
592 hr = SHELL32_GetDisplayNameOfChild (iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len);
595 if (SUCCEEDED (hr)) {
596 strRet->uType = STRRET_CSTR;
597 lstrcpynA (strRet->u.cStr, szPath, MAX_PATH);
600 TRACE ("-- (%p)->(%s)\n", This, szPath);
601 return hr;
604 /**************************************************************************
605 * ISF_MyComputer_fnSetNameOf
606 * Changes the name of a file object or subfolder, possibly changing its item
607 * identifier in the process.
609 * PARAMETERS
610 * HWND hwndOwner, //[in ] Owner window for output
611 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
612 * LPCOLESTR lpszName, //[in ] the items new display name
613 * DWORD dwFlags, //[in ] SHGNO formatting flags
614 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
616 static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
617 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
619 IGenericSFImpl *This = (IGenericSFImpl *)iface;
620 FIXME ("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
621 return E_FAIL;
624 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (IShellFolder2 * iface, GUID * pguid)
626 IGenericSFImpl *This = (IGenericSFImpl *)iface;
627 FIXME ("(%p)\n", This);
628 return E_NOTIMPL;
630 static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
632 IGenericSFImpl *This = (IGenericSFImpl *)iface;
633 FIXME ("(%p)\n", This);
634 return E_NOTIMPL;
636 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
638 IGenericSFImpl *This = (IGenericSFImpl *)iface;
640 TRACE ("(%p)\n", This);
642 if (pSort) *pSort = 0;
643 if (pDisplay) *pDisplay = 0;
644 return S_OK;
646 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
648 IGenericSFImpl *This = (IGenericSFImpl *)iface;
650 TRACE ("(%p)\n", This);
652 if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS) return E_INVALIDARG;
653 *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
654 return S_OK;
656 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
658 IGenericSFImpl *This = (IGenericSFImpl *)iface;
659 FIXME ("(%p)\n", This);
660 return E_NOTIMPL;
663 /* FIXME: drive size >4GB is rolling over */
664 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
666 IGenericSFImpl *This = (IGenericSFImpl *)iface;
667 HRESULT hr;
669 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
671 if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
672 return E_INVALIDARG;
674 if (!pidl) {
675 psd->fmt = MyComputerSFHeader[iColumn].fmt;
676 psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
677 psd->str.uType = STRRET_CSTR;
678 LoadStringA (shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
679 return S_OK;
680 } else {
681 char szPath[MAX_PATH];
682 ULARGE_INTEGER ulBytes;
684 psd->str.u.cStr[0] = 0x00;
685 psd->str.uType = STRRET_CSTR;
686 switch (iColumn) {
687 case 0: /* name */
688 hr = IShellFolder_GetDisplayNameOf (iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
689 break;
690 case 1: /* type */
691 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
692 break;
693 case 2: /* total size */
694 if (_ILIsDrive (pidl)) {
695 _ILSimpleGetText (pidl, szPath, MAX_PATH);
696 GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL);
697 StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
699 break;
700 case 3: /* free size */
701 if (_ILIsDrive (pidl)) {
702 _ILSimpleGetText (pidl, szPath, MAX_PATH);
703 GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL);
704 StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
706 break;
708 hr = S_OK;
711 return hr;
713 static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID (IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
715 IGenericSFImpl *This = (IGenericSFImpl *)iface;
716 FIXME ("(%p)\n", This);
717 return E_NOTIMPL;
720 static IShellFolder2Vtbl vt_ShellFolder2 =
722 ISF_MyComputer_fnQueryInterface,
723 ISF_MyComputer_fnAddRef,
724 ISF_MyComputer_fnRelease,
725 ISF_MyComputer_fnParseDisplayName,
726 ISF_MyComputer_fnEnumObjects,
727 ISF_MyComputer_fnBindToObject,
728 ISF_MyComputer_fnBindToStorage,
729 ISF_MyComputer_fnCompareIDs,
730 ISF_MyComputer_fnCreateViewObject,
731 ISF_MyComputer_fnGetAttributesOf,
732 ISF_MyComputer_fnGetUIObjectOf,
733 ISF_MyComputer_fnGetDisplayNameOf,
734 ISF_MyComputer_fnSetNameOf,
735 /* ShellFolder2 */
736 ISF_MyComputer_fnGetDefaultSearchGUID,
737 ISF_MyComputer_fnEnumSearches,
738 ISF_MyComputer_fnGetDefaultColumn,
739 ISF_MyComputer_fnGetDefaultColumnState,
740 ISF_MyComputer_fnGetDetailsEx,
741 ISF_MyComputer_fnGetDetailsOf,
742 ISF_MyComputer_fnMapColumnToSCID
745 /************************************************************************
746 * IMCFldr_PersistFolder2_QueryInterface
748 static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj)
750 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
752 TRACE ("(%p)\n", This);
754 return IUnknown_QueryInterface (_IUnknown_ (This), iid, ppvObj);
757 /************************************************************************
758 * IMCFldr_PersistFolder2_AddRef
760 static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
762 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
764 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
766 return IUnknown_AddRef (_IUnknown_ (This));
769 /************************************************************************
770 * ISFPersistFolder_Release
772 static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface)
774 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
776 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
778 return IUnknown_Release (_IUnknown_ (This));
781 /************************************************************************
782 * IMCFldr_PersistFolder2_GetClassID
784 static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (IPersistFolder2 * iface, CLSID * lpClassId)
786 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
788 TRACE ("(%p)\n", This);
790 if (!lpClassId)
791 return E_POINTER;
792 *lpClassId = CLSID_MyComputer;
794 return S_OK;
797 /************************************************************************
798 * IMCFldr_PersistFolder2_Initialize
800 * NOTES: it makes no sense to change the pidl
802 static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (IPersistFolder2 * iface, LPCITEMIDLIST pidl)
804 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
805 TRACE ("(%p)->(%p)\n", This, pidl);
806 return E_NOTIMPL;
809 /**************************************************************************
810 * IPersistFolder2_fnGetCurFolder
812 static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (IPersistFolder2 * iface, LPITEMIDLIST * pidl)
814 _ICOM_THIS_From_IPersistFolder2 (IGenericSFImpl, iface);
816 TRACE ("(%p)->(%p)\n", This, pidl);
818 if (!pidl)
819 return E_POINTER;
820 *pidl = ILClone (This->pidlRoot);
821 return S_OK;
824 static IPersistFolder2Vtbl vt_PersistFolder2 =
826 IMCFldr_PersistFolder2_QueryInterface,
827 IMCFldr_PersistFolder2_AddRef,
828 IMCFldr_PersistFolder2_Release,
829 IMCFldr_PersistFolder2_GetClassID,
830 IMCFldr_PersistFolder2_Initialize,
831 IMCFldr_PersistFolder2_GetCurFolder