2 * Virtual Workplace folder
4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998, 1999, 2002 Juergen Schmied
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
31 #define NONAMELESSUNION
32 #define NONAMELESSSTRUCT
42 #include "enumidlist.h"
43 #include "undocshell.h"
44 #include "shell32_main.h"
47 #include "wine/debug.h"
51 WINE_DEFAULT_DEBUG_CHANNEL (shell);
53 /***********************************************************************
54 * IShellFolder implementation
58 const IShellFolder2Vtbl *lpVtbl;
60 const IPersistFolder2Vtbl *lpVtblPersistFolder2;
62 /* both paths are parsible from the desktop */
63 LPITEMIDLIST pidlRoot; /* absolute pidl */
64 } IMyComputerFolderImpl;
66 static const IShellFolder2Vtbl vt_ShellFolder2;
67 static const IPersistFolder2Vtbl vt_PersistFolder2;
69 static inline IMyComputerFolderImpl *impl_from_IPersistFolder2( IPersistFolder2 *iface )
71 return (IMyComputerFolderImpl *)((char*)iface - FIELD_OFFSET(IMyComputerFolderImpl, lpVtblPersistFolder2));
76 converts This to an interface pointer
78 #define _IShellFolder_(This) ((IShellFolder*)&(This)->lpVtbl)
79 #define _IShellFolder2_(This) (&(This)->lpVtbl)
81 #define _IPersist_(This) (&(This)->lpVtblPersistFolder2)
82 #define _IPersistFolder_(This) (&(This)->lpVtblPersistFolder2)
83 #define _IPersistFolder2_(This) (&(This)->lpVtblPersistFolder2)
85 /***********************************************************************
86 * IShellFolder [MyComputer] implementation
89 static const shvheader mycomputer_header[] = {
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 sizeof(mycomputer_header)/sizeof(shvheader)
98 /**************************************************************************
99 * ISF_MyComputer_Constructor
101 HRESULT WINAPI ISF_MyComputer_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
103 IMyComputerFolderImpl *sf;
105 TRACE ("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid (riid));
110 return CLASS_E_NOAGGREGATION;
112 sf = LocalAlloc (LMEM_ZEROINIT, sizeof (IMyComputerFolderImpl));
114 return E_OUTOFMEMORY;
117 sf->lpVtbl = &vt_ShellFolder2;
118 sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
119 sf->pidlRoot = _ILCreateMyComputer (); /* my qualified pidl */
121 if (FAILED (IUnknown_QueryInterface ((IShellFolder2 *)sf, riid, ppv)))
123 IUnknown_Release ((IShellFolder2 *) sf);
124 return E_NOINTERFACE;
127 TRACE ("--(%p)\n", sf);
131 /**************************************************************************
132 * ISF_MyComputer_fnQueryInterface
134 * NOTES supports not IPersist/IPersistFolder
136 static HRESULT WINAPI ISF_MyComputer_fnQueryInterface (IShellFolder2 *iface,
137 REFIID riid, LPVOID *ppvObj)
139 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
141 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
145 if (IsEqualIID (riid, &IID_IUnknown) ||
146 IsEqualIID (riid, &IID_IShellFolder) ||
147 IsEqualIID (riid, &IID_IShellFolder2))
151 else if (IsEqualIID (riid, &IID_IPersist) ||
152 IsEqualIID (riid, &IID_IPersistFolder) ||
153 IsEqualIID (riid, &IID_IPersistFolder2))
155 *ppvObj = _IPersistFolder2_ (This);
160 IUnknown_AddRef ((IUnknown *) (*ppvObj));
161 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
164 TRACE ("-- Interface: E_NOINTERFACE\n");
165 return E_NOINTERFACE;
168 static ULONG WINAPI ISF_MyComputer_fnAddRef (IShellFolder2 * iface)
170 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
171 ULONG refCount = InterlockedIncrement(&This->ref);
173 TRACE ("(%p)->(count=%u)\n", This, refCount - 1);
178 static ULONG WINAPI ISF_MyComputer_fnRelease (IShellFolder2 * iface)
180 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
181 ULONG refCount = InterlockedDecrement(&This->ref);
183 TRACE ("(%p)->(count=%u)\n", This, refCount + 1);
187 TRACE ("-- destroying IShellFolder(%p)\n", This);
188 SHFree (This->pidlRoot);
194 /**************************************************************************
195 * ISF_MyComputer_fnParseDisplayName
197 static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName (IShellFolder2 *iface,
198 HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName,
199 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
201 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
202 HRESULT hr = E_INVALIDARG;
203 LPCWSTR szNext = NULL;
204 WCHAR szElement[MAX_PATH];
205 LPITEMIDLIST pidlTemp = NULL;
208 TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This,
209 hwndOwner, pbc, lpszDisplayName, debugstr_w (lpszDisplayName),
210 pchEaten, ppidl, pdwAttributes);
214 *pchEaten = 0; /* strange but like the original */
216 /* handle CLSID paths */
217 if (lpszDisplayName[0] == ':' && lpszDisplayName[1] == ':')
219 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
220 TRACE ("-- element: %s\n", debugstr_w (szElement));
221 SHCLSIDFromStringW (szElement + 2, &clsid);
222 pidlTemp = _ILCreateGuid (PT_GUID, &clsid);
224 /* do we have an absolute path name ? */
225 else if (PathGetDriveNumberW (lpszDisplayName) >= 0 &&
226 lpszDisplayName[2] == (WCHAR) '\\')
228 szNext = GetNextElementW (lpszDisplayName, szElement, MAX_PATH);
229 /* make drive letter uppercase to enable PIDL comparison */
230 szElement[0] = toupper(szElement[0]);
231 pidlTemp = _ILCreateDrive (szElement);
234 if (szNext && *szNext)
236 hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp,
237 (LPOLESTR) szNext, pchEaten, pdwAttributes);
241 if (pdwAttributes && *pdwAttributes)
242 SHELL32_GetItemAttributes (_IShellFolder_ (This),
243 pidlTemp, pdwAttributes);
249 TRACE ("(%p)->(-- ret=0x%08x)\n", This, hr);
254 /* retrieve a map of drives that should be displayed */
255 static DWORD get_drive_map(void)
257 static const WCHAR policiesW[] = {'S','o','f','t','w','a','r','e','\\',
258 'M','i','c','r','o','s','o','f','t','\\',
259 'W','i','n','d','o','w','s','\\',
260 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
261 'P','o','l','i','c','i','e','s','\\',
262 'E','x','p','l','o','r','e','r',0};
263 static const WCHAR nodrivesW[] = {'N','o','D','r','i','v','e','s',0};
264 static DWORD drive_mask, init_done;
268 DWORD type, size, data, mask = 0;
271 if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, policiesW, &hkey ))
274 if (!RegQueryValueExW( hkey, nodrivesW, NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
278 if (!RegOpenKeyW( HKEY_CURRENT_USER, policiesW, &hkey ))
281 if (!RegQueryValueExW( hkey, nodrivesW, NULL, &type, (LPBYTE)&data, &size ) && type == REG_DWORD)
289 return GetLogicalDrives() & ~drive_mask;
292 /**************************************************************************
293 * CreateMyCompEnumList()
295 static const WCHAR MyComputer_NameSpaceW[] = { 'S','O','F','T','W','A','R','E',
296 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
297 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
298 'o','r','e','r','\\','M','y','C','o','m','p','u','t','e','r','\\','N','a','m',
299 'e','s','p','a','c','e','\0' };
301 static BOOL CreateMyCompEnumList(IEnumIDList *list, DWORD dwFlags)
305 TRACE("(%p)->(flags=0x%08x)\n", list, dwFlags);
307 /* enumerate the folders */
308 if (dwFlags & SHCONTF_FOLDERS)
310 WCHAR wszDriveName[] = {'A', ':', '\\', '\0'};
311 DWORD dwDrivemap = get_drive_map();
315 while (ret && wszDriveName[0]<='Z')
317 if(dwDrivemap & 0x00000001L)
318 ret = AddToEnumList(list, _ILCreateDrive(wszDriveName));
320 dwDrivemap = dwDrivemap >> 1;
323 TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list);
324 for (i=0; i<2; i++) {
325 if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
326 MyComputer_NameSpaceW, 0, KEY_READ, &hkey))
336 size = sizeof(iid) / sizeof(iid[0]);
337 r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
338 if (ERROR_SUCCESS == r)
340 /* FIXME: shell extensions, shouldn't the type be
342 ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid));
345 else if (ERROR_NO_MORE_ITEMS == r)
357 /**************************************************************************
358 * ISF_MyComputer_fnEnumObjects
360 static HRESULT WINAPI ISF_MyComputer_fnEnumObjects (IShellFolder2 *iface,
361 HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
363 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
365 TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This,
366 hwndOwner, dwFlags, ppEnumIDList);
368 *ppEnumIDList = IEnumIDList_Constructor();
370 CreateMyCompEnumList(*ppEnumIDList, dwFlags);
372 TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);
374 return (*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
377 /**************************************************************************
378 * ISF_MyComputer_fnBindToObject
380 static HRESULT WINAPI ISF_MyComputer_fnBindToObject (IShellFolder2 *iface,
381 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
383 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
385 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This,
386 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
388 return SHELL32_BindToChild (This->pidlRoot, NULL, pidl, riid, ppvOut);
391 /**************************************************************************
392 * ISF_MyComputer_fnBindToStorage
394 static HRESULT WINAPI ISF_MyComputer_fnBindToStorage (IShellFolder2 * iface,
395 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
397 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
399 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This,
400 pidl, pbcReserved, shdebugstr_guid (riid), ppvOut);
406 /**************************************************************************
407 * ISF_MyComputer_fnCompareIDs
410 static HRESULT WINAPI ISF_MyComputer_fnCompareIDs (IShellFolder2 *iface,
411 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
413 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
416 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
417 hr = SHELL32_CompareIDs (_IShellFolder_ (This), lParam, pidl1, pidl2);
418 TRACE ("-- 0x%08x\n", hr);
422 /**************************************************************************
423 * ISF_MyComputer_fnCreateViewObject
425 static HRESULT WINAPI ISF_MyComputer_fnCreateViewObject (IShellFolder2 *iface,
426 HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
428 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
429 LPSHELLVIEW pShellView;
430 HRESULT hr = E_INVALIDARG;
432 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This,
433 hwndOwner, shdebugstr_guid (riid), ppvOut);
440 if (IsEqualIID (riid, &IID_IDropTarget))
442 WARN ("IDropTarget not implemented\n");
445 else if (IsEqualIID (riid, &IID_IContextMenu))
447 WARN ("IContextMenu not implemented\n");
450 else if (IsEqualIID (riid, &IID_IShellView))
452 pShellView = IShellView_Constructor ((IShellFolder *) iface);
455 hr = IShellView_QueryInterface (pShellView, riid, ppvOut);
456 IShellView_Release (pShellView);
459 TRACE ("-- (%p)->(interface=%p)\n", This, ppvOut);
463 /**************************************************************************
464 * ISF_MyComputer_fnGetAttributesOf
466 static HRESULT WINAPI ISF_MyComputer_fnGetAttributesOf (IShellFolder2 * iface,
467 UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
469 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
472 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
473 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
484 IShellFolder *psfParent = NULL;
485 LPCITEMIDLIST rpidl = NULL;
487 hr = SHBindToParent(This->pidlRoot, &IID_IShellFolder, (LPVOID*)&psfParent, &rpidl);
489 SHELL32_GetItemAttributes (psfParent, rpidl, rgfInOut);
490 IShellFolder_Release(psfParent);
493 while (cidl > 0 && *apidl) {
495 SHELL32_GetItemAttributes (_IShellFolder_ (This), *apidl, rgfInOut);
500 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
501 *rgfInOut &= ~SFGAO_VALIDATE;
503 TRACE ("-- result=0x%08x\n", *rgfInOut);
507 /**************************************************************************
508 * ISF_MyComputer_fnGetUIObjectOf
511 * hwndOwner [in] Parent window for any output
512 * cidl [in] array size
513 * apidl [in] simple pidl array
514 * riid [in] Requested Interface
515 * prgfInOut [ ] reserved
516 * ppvObject [out] Resulting Interface
519 static HRESULT WINAPI ISF_MyComputer_fnGetUIObjectOf (IShellFolder2 * iface,
520 HWND hwndOwner, UINT cidl, LPCITEMIDLIST * apidl, REFIID riid,
521 UINT * prgfInOut, LPVOID * ppvOut)
523 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
526 IUnknown *pObj = NULL;
527 HRESULT hr = E_INVALIDARG;
529 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This,
530 hwndOwner, cidl, apidl, shdebugstr_guid (riid), prgfInOut, ppvOut);
537 if (IsEqualIID (riid, &IID_IContextMenu) && (cidl >= 1))
539 pObj = (LPUNKNOWN) ISvItemCm_Constructor ((IShellFolder *) iface,
540 This->pidlRoot, apidl, cidl);
543 else if (IsEqualIID (riid, &IID_IDataObject) && (cidl >= 1))
545 pObj = (LPUNKNOWN) IDataObject_Constructor (hwndOwner,
546 This->pidlRoot, apidl, cidl);
549 else if (IsEqualIID (riid, &IID_IExtractIconA) && (cidl == 1))
551 pidl = ILCombine (This->pidlRoot, apidl[0]);
552 pObj = (LPUNKNOWN) IExtractIconA_Constructor (pidl);
556 else if (IsEqualIID (riid, &IID_IExtractIconW) && (cidl == 1))
558 pidl = ILCombine (This->pidlRoot, apidl[0]);
559 pObj = (LPUNKNOWN) IExtractIconW_Constructor (pidl);
563 else if (IsEqualIID (riid, &IID_IDropTarget) && (cidl >= 1))
565 hr = IShellFolder_QueryInterface (iface, &IID_IDropTarget,
568 else if ((IsEqualIID(riid,&IID_IShellLinkW) ||
569 IsEqualIID(riid,&IID_IShellLinkA)) && (cidl == 1))
571 pidl = ILCombine (This->pidlRoot, apidl[0]);
572 hr = IShellLink_ConstructFromFile(NULL, riid, pidl, (LPVOID*) &pObj);
578 if (SUCCEEDED(hr) && !pObj)
582 TRACE ("(%p)->hr=0x%08x\n", This, hr);
586 /**************************************************************************
587 * ISF_MyComputer_fnGetDisplayNameOf
589 static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2 *iface,
590 LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
592 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
597 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
603 pszPath = CoTaskMemAlloc((MAX_PATH +1) * sizeof(WCHAR));
605 return E_OUTOFMEMORY;
611 /* parsing name like ::{...} */
614 SHELL32_GUIDToStringW(&CLSID_MyComputer, &pszPath[2]);
616 else if (_ILIsPidlSimple(pidl))
618 /* take names of special folders only if its only this folder */
619 if (_ILIsSpecialFolder(pidl))
623 clsid = _ILGetGUIDPointer (pidl);
626 if (GET_SHGDN_FOR (dwFlags) & SHGDN_FORPARSING)
628 static const WCHAR clsidW[] =
629 { 'C','L','S','I','D','\\',0 };
630 static const WCHAR shellfolderW[] =
631 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
632 static const WCHAR wantsForParsingW[] =
633 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
635 int bWantsForParsing = FALSE;
636 WCHAR szRegPath[100];
640 * We can only get a filesystem path from a shellfolder
641 * if the value WantsFORPARSING exists in
642 * CLSID\\{...}\\shellfolder
643 * exception: the MyComputer folder has this keys not
644 * but like any filesystem backed
645 * folder it needs these behaviour
647 * Get the "WantsFORPARSING" flag from the registry
650 lstrcpyW (szRegPath, clsidW);
651 SHELL32_GUIDToStringW (clsid, &szRegPath[6]);
652 lstrcatW (szRegPath, shellfolderW);
653 r = SHGetValueW (HKEY_CLASSES_ROOT, szRegPath,
654 wantsForParsingW, NULL, NULL, NULL);
655 if (r == ERROR_SUCCESS)
656 bWantsForParsing = TRUE;
658 if ((GET_SHGDN_RELATION (dwFlags) == SHGDN_NORMAL) &&
662 * We need the filesystem path to the destination folder
663 * Only the folder itself can know it
665 hr = SHELL32_GetDisplayNameOfChild (iface, pidl,
666 dwFlags, pszPath, MAX_PATH);
672 /* parsing name like ::{...} */
676 p += SHELL32_GUIDToStringW(&CLSID_MyComputer, p);
683 SHELL32_GUIDToStringW(clsid, p);
688 /* user friendly name */
689 HCR_GetClassNameW (clsid, pszPath, MAX_PATH);
694 /* append my own path */
695 _ILSimpleGetTextW (pidl, pszPath, MAX_PATH);
698 else if (_ILIsDrive(pidl))
700 _ILSimpleGetTextW (pidl, pszPath, MAX_PATH); /* append my own path */
702 /* long view "lw_name (C:)" */
703 if (!(dwFlags & SHGDN_FORPARSING))
705 DWORD dwVolumeSerialNumber, dwMaximumComponetLength, dwFileSystemFlags;
706 WCHAR wszDrive[18] = {0};
707 static const WCHAR wszOpenBracket[] = {' ','(',0};
708 static const WCHAR wszCloseBracket[] = {')',0};
710 GetVolumeInformationW (pszPath, wszDrive,
711 sizeof(wszDrive)/sizeof(wszDrive[0]) - 6,
712 &dwVolumeSerialNumber,
713 &dwMaximumComponetLength, &dwFileSystemFlags, NULL, 0);
714 strcatW (wszDrive, wszOpenBracket);
715 lstrcpynW (wszDrive + strlenW(wszDrive), pszPath, 3);
716 strcatW (wszDrive, wszCloseBracket);
717 strcpyW (pszPath, wszDrive);
722 /* Neither a shell namespace extension nor a drive letter. */
723 ERR("Wrong pidl type\n");
724 CoTaskMemFree(pszPath);
730 /* Complex pidl. Let the child folder do the work */
731 hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, pszPath, MAX_PATH);
736 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
737 if (GetVersion() & 0x80000000)
739 strRet->uType = STRRET_CSTR;
740 if (!WideCharToMultiByte(CP_ACP, 0, pszPath, -1, strRet->u.cStr, MAX_PATH,
742 strRet->u.cStr[0] = '\0';
743 CoTaskMemFree(pszPath);
747 strRet->uType = STRRET_WSTR;
748 strRet->u.pOleStr = pszPath;
752 CoTaskMemFree(pszPath);
754 TRACE ("-- (%p)->(%s)\n", This, strRet->uType == STRRET_CSTR ? strRet->u.cStr : debugstr_w(strRet->u.pOleStr));
758 /**************************************************************************
759 * ISF_MyComputer_fnSetNameOf
760 * Changes the name of a file object or subfolder, possibly changing its item
761 * identifier in the process.
764 * hwndOwner [in] Owner window for output
765 * pidl [in] simple pidl of item to change
766 * lpszName [in] the items new display name
767 * dwFlags [in] SHGNO formatting flags
768 * ppidlOut [out] simple pidl returned
770 static HRESULT WINAPI ISF_MyComputer_fnSetNameOf (
771 IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl,
772 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
774 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
775 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This,
776 hwndOwner, pidl, debugstr_w (lpName), dwFlags, pPidlOut);
780 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID (
781 IShellFolder2 * iface, GUID * pguid)
783 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
784 FIXME ("(%p)\n", This);
787 static HRESULT WINAPI ISF_MyComputer_fnEnumSearches (
788 IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
790 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
791 FIXME ("(%p)\n", This);
794 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn (
795 IShellFolder2 *iface, DWORD dwRes, ULONG *pSort, ULONG *pDisplay)
797 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
799 TRACE ("(%p)\n", This);
807 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState (
808 IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
810 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
812 TRACE ("(%p)->(%d %p)\n", This, iColumn, pcsFlags);
814 if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
817 *pcsFlags = mycomputer_header[iColumn].pcsFlags;
822 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx (IShellFolder2 * iface,
823 LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
825 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
826 FIXME ("(%p)\n", This);
830 /* FIXME: drive size >4GB is rolling over */
831 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf (IShellFolder2 *iface,
832 LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS *psd)
834 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
835 char szPath[MAX_PATH];
836 ULARGE_INTEGER ulBytes;
839 TRACE ("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
841 if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS)
845 return SHELL32_GetColumnDetails(mycomputer_header, iColumn, psd);
847 psd->str.u.cStr[0] = 0;
848 psd->str.uType = STRRET_CSTR;
853 hr = IShellFolder_GetDisplayNameOf (iface, pidl,
854 SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
857 _ILGetFileType (pidl, psd->str.u.cStr, MAX_PATH);
859 case 2: /* total size */
860 if (_ILIsDrive (pidl))
862 _ILSimpleGetText (pidl, szPath, MAX_PATH);
863 GetDiskFreeSpaceExA (szPath, NULL, &ulBytes, NULL);
864 StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
867 case 3: /* free size */
868 if (_ILIsDrive (pidl))
870 _ILSimpleGetText (pidl, szPath, MAX_PATH);
871 GetDiskFreeSpaceExA (szPath, &ulBytes, NULL, NULL);
872 StrFormatByteSizeA (ulBytes.u.LowPart, psd->str.u.cStr, MAX_PATH);
880 static HRESULT WINAPI ISF_MyComputer_fnMapColumnToSCID (
881 IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
883 IMyComputerFolderImpl *This = (IMyComputerFolderImpl *)iface;
884 FIXME ("(%p)\n", This);
888 static const IShellFolder2Vtbl vt_ShellFolder2 =
890 ISF_MyComputer_fnQueryInterface,
891 ISF_MyComputer_fnAddRef,
892 ISF_MyComputer_fnRelease,
893 ISF_MyComputer_fnParseDisplayName,
894 ISF_MyComputer_fnEnumObjects,
895 ISF_MyComputer_fnBindToObject,
896 ISF_MyComputer_fnBindToStorage,
897 ISF_MyComputer_fnCompareIDs,
898 ISF_MyComputer_fnCreateViewObject,
899 ISF_MyComputer_fnGetAttributesOf,
900 ISF_MyComputer_fnGetUIObjectOf,
901 ISF_MyComputer_fnGetDisplayNameOf,
902 ISF_MyComputer_fnSetNameOf,
904 ISF_MyComputer_fnGetDefaultSearchGUID,
905 ISF_MyComputer_fnEnumSearches,
906 ISF_MyComputer_fnGetDefaultColumn,
907 ISF_MyComputer_fnGetDefaultColumnState,
908 ISF_MyComputer_fnGetDetailsEx,
909 ISF_MyComputer_fnGetDetailsOf,
910 ISF_MyComputer_fnMapColumnToSCID
913 /************************************************************************
914 * IMCFldr_PersistFolder2_QueryInterface
916 static HRESULT WINAPI IMCFldr_PersistFolder2_QueryInterface (
917 IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObj)
919 IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
920 TRACE ("(%p)\n", This);
921 return IUnknown_QueryInterface ((IShellFolder2 *)This, iid, ppvObj);
924 /************************************************************************
925 * IMCFldr_PersistFolder2_AddRef
927 static ULONG WINAPI IMCFldr_PersistFolder2_AddRef (IPersistFolder2 * iface)
929 IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
930 TRACE ("(%p)->(count=%u)\n", This, This->ref);
931 return IUnknown_AddRef ((IShellFolder2 *)This);
934 /************************************************************************
935 * ISFPersistFolder_Release
937 static ULONG WINAPI IMCFldr_PersistFolder2_Release (IPersistFolder2 * iface)
939 IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
940 TRACE ("(%p)->(count=%u)\n", This, This->ref);
941 return IUnknown_Release ((IShellFolder2 *)This);
944 /************************************************************************
945 * IMCFldr_PersistFolder2_GetClassID
947 static HRESULT WINAPI IMCFldr_PersistFolder2_GetClassID (
948 IPersistFolder2 * iface, CLSID * lpClassId)
950 IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
952 TRACE ("(%p)\n", This);
956 *lpClassId = CLSID_MyComputer;
961 /************************************************************************
962 * IMCFldr_PersistFolder2_Initialize
964 * NOTES: it makes no sense to change the pidl
966 static HRESULT WINAPI IMCFldr_PersistFolder2_Initialize (
967 IPersistFolder2 * iface, LPCITEMIDLIST pidl)
969 IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
970 TRACE ("(%p)->(%p)\n", This, pidl);
974 /**************************************************************************
975 * IPersistFolder2_fnGetCurFolder
977 static HRESULT WINAPI IMCFldr_PersistFolder2_GetCurFolder (
978 IPersistFolder2 * iface, LPITEMIDLIST * pidl)
980 IMyComputerFolderImpl *This = impl_from_IPersistFolder2(iface);
982 TRACE ("(%p)->(%p)\n", This, pidl);
986 *pidl = ILClone (This->pidlRoot);
990 static const IPersistFolder2Vtbl vt_PersistFolder2 =
992 IMCFldr_PersistFolder2_QueryInterface,
993 IMCFldr_PersistFolder2_AddRef,
994 IMCFldr_PersistFolder2_Release,
995 IMCFldr_PersistFolder2_GetClassID,
996 IMCFldr_PersistFolder2_Initialize,
997 IMCFldr_PersistFolder2_GetCurFolder