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 "undocshell.h"
43 #include "shell32_main.h"
46 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL (shell
);
52 /***********************************************************************
53 * IShellFolder implementation
57 IShellFolder2 IShellFolder2_iface
;
58 IPersistFolder2 IPersistFolder2_iface
;
61 /* both paths are parsible from the desktop */
62 LPITEMIDLIST pidlRoot
; /* absolute pidl */
63 } IMyComputerFolderImpl
;
65 static const IShellFolder2Vtbl vt_ShellFolder2
;
66 static const IPersistFolder2Vtbl vt_PersistFolder2
;
68 static inline IMyComputerFolderImpl
*impl_from_IShellFolder2(IShellFolder2
*iface
)
70 return CONTAINING_RECORD(iface
, IMyComputerFolderImpl
, IShellFolder2_iface
);
73 static inline IMyComputerFolderImpl
*impl_from_IPersistFolder2(IPersistFolder2
*iface
)
75 return CONTAINING_RECORD(iface
, IMyComputerFolderImpl
, IPersistFolder2_iface
);
79 /***********************************************************************
80 * IShellFolder [MyComputer] implementation
83 static const shvheader mycomputer_header
[] = {
84 {IDS_SHV_COLUMN1
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},
85 {IDS_SHV_COLUMN3
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
86 {IDS_SHV_COLUMN6
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
87 {IDS_SHV_COLUMN7
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 10},
90 #define MYCOMPUTERSHELLVIEWCOLUMNS sizeof(mycomputer_header)/sizeof(shvheader)
92 /**************************************************************************
93 * ISF_MyComputer_Constructor
95 HRESULT WINAPI
ISF_MyComputer_Constructor (IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
97 IMyComputerFolderImpl
*sf
;
99 TRACE ("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid (riid
));
104 return CLASS_E_NOAGGREGATION
;
106 sf
= LocalAlloc (LMEM_ZEROINIT
, sizeof (IMyComputerFolderImpl
));
108 return E_OUTOFMEMORY
;
111 sf
->IShellFolder2_iface
.lpVtbl
= &vt_ShellFolder2
;
112 sf
->IPersistFolder2_iface
.lpVtbl
= &vt_PersistFolder2
;
113 sf
->pidlRoot
= _ILCreateMyComputer (); /* my qualified pidl */
115 if (FAILED (IShellFolder2_QueryInterface (&sf
->IShellFolder2_iface
, riid
, ppv
)))
117 IShellFolder2_Release (&sf
->IShellFolder2_iface
);
118 return E_NOINTERFACE
;
121 TRACE ("--(%p)\n", sf
);
125 /**************************************************************************
126 * ISF_MyComputer_fnQueryInterface
128 * NOTES supports not IPersist/IPersistFolder
130 static HRESULT WINAPI
ISF_MyComputer_fnQueryInterface (IShellFolder2
*iface
,
131 REFIID riid
, LPVOID
*ppvObj
)
133 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
135 TRACE ("(%p)->(%s,%p)\n", This
, shdebugstr_guid (riid
), ppvObj
);
139 if (IsEqualIID (riid
, &IID_IUnknown
) ||
140 IsEqualIID (riid
, &IID_IShellFolder
) ||
141 IsEqualIID (riid
, &IID_IShellFolder2
))
145 else if (IsEqualIID (riid
, &IID_IPersist
) ||
146 IsEqualIID (riid
, &IID_IPersistFolder
) ||
147 IsEqualIID (riid
, &IID_IPersistFolder2
))
149 *ppvObj
= &This
->IPersistFolder2_iface
;
154 IUnknown_AddRef ((IUnknown
*) (*ppvObj
));
155 TRACE ("-- Interface: (%p)->(%p)\n", ppvObj
, *ppvObj
);
158 TRACE ("-- Interface: E_NOINTERFACE\n");
159 return E_NOINTERFACE
;
162 static ULONG WINAPI
ISF_MyComputer_fnAddRef (IShellFolder2
* iface
)
164 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
165 ULONG refCount
= InterlockedIncrement(&This
->ref
);
167 TRACE ("(%p)->(count=%u)\n", This
, refCount
- 1);
172 static ULONG WINAPI
ISF_MyComputer_fnRelease (IShellFolder2
* iface
)
174 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
175 ULONG refCount
= InterlockedDecrement(&This
->ref
);
177 TRACE ("(%p)->(count=%u)\n", This
, refCount
+ 1);
181 TRACE ("-- destroying IShellFolder(%p)\n", This
);
182 SHFree (This
->pidlRoot
);
188 /**************************************************************************
189 * ISF_MyComputer_fnParseDisplayName
191 static HRESULT WINAPI
ISF_MyComputer_fnParseDisplayName (IShellFolder2
*iface
,
192 HWND hwndOwner
, LPBC pbc
, LPOLESTR lpszDisplayName
,
193 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
195 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
196 HRESULT hr
= E_INVALIDARG
;
197 LPCWSTR szNext
= NULL
;
198 WCHAR szElement
[MAX_PATH
];
199 LPITEMIDLIST pidlTemp
= NULL
;
202 TRACE("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n", This
,
203 hwndOwner
, pbc
, lpszDisplayName
, debugstr_w (lpszDisplayName
),
204 pchEaten
, ppidl
, pdwAttributes
);
208 *pchEaten
= 0; /* strange but like the original */
210 /* handle CLSID paths */
211 if (lpszDisplayName
[0] == ':' && lpszDisplayName
[1] == ':')
213 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
214 TRACE ("-- element: %s\n", debugstr_w (szElement
));
215 SHCLSIDFromStringW (szElement
+ 2, &clsid
);
216 pidlTemp
= _ILCreateGuid (PT_GUID
, &clsid
);
218 /* do we have an absolute path name ? */
219 else if (PathGetDriveNumberW (lpszDisplayName
) >= 0 &&
220 lpszDisplayName
[2] == (WCHAR
) '\\')
222 szNext
= GetNextElementW (lpszDisplayName
, szElement
, MAX_PATH
);
223 /* make drive letter uppercase to enable PIDL comparison */
224 szElement
[0] = toupper(szElement
[0]);
225 pidlTemp
= _ILCreateDrive (szElement
);
228 if (szNext
&& *szNext
)
230 hr
= SHELL32_ParseNextElement (iface
, hwndOwner
, pbc
, &pidlTemp
,
231 (LPOLESTR
) szNext
, pchEaten
, pdwAttributes
);
235 if (pdwAttributes
&& *pdwAttributes
)
236 SHELL32_GetItemAttributes ((IShellFolder
*)&This
->IShellFolder2_iface
, pidlTemp
,
243 TRACE ("(%p)->(-- ret=0x%08x)\n", This
, hr
);
248 /* retrieve a map of drives that should be displayed */
249 static DWORD
get_drive_map(void)
251 static const WCHAR policiesW
[] = {'S','o','f','t','w','a','r','e','\\',
252 'M','i','c','r','o','s','o','f','t','\\',
253 'W','i','n','d','o','w','s','\\',
254 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
255 'P','o','l','i','c','i','e','s','\\',
256 'E','x','p','l','o','r','e','r',0};
257 static const WCHAR nodrivesW
[] = {'N','o','D','r','i','v','e','s',0};
258 static DWORD drive_mask
, init_done
;
262 DWORD type
, size
, data
, mask
= 0;
265 if (!RegOpenKeyW( HKEY_LOCAL_MACHINE
, policiesW
, &hkey
))
268 if (!RegQueryValueExW( hkey
, nodrivesW
, NULL
, &type
, (LPBYTE
)&data
, &size
) && type
== REG_DWORD
)
272 if (!RegOpenKeyW( HKEY_CURRENT_USER
, policiesW
, &hkey
))
275 if (!RegQueryValueExW( hkey
, nodrivesW
, NULL
, &type
, (LPBYTE
)&data
, &size
) && type
== REG_DWORD
)
283 return GetLogicalDrives() & ~drive_mask
;
286 /**************************************************************************
287 * CreateMyCompEnumList()
289 static const WCHAR MyComputer_NameSpaceW
[] = { 'S','O','F','T','W','A','R','E',
290 '\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
291 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','E','x','p','l',
292 'o','r','e','r','\\','M','y','C','o','m','p','u','t','e','r','\\','N','a','m',
293 'e','s','p','a','c','e','\0' };
295 static BOOL
CreateMyCompEnumList(IEnumIDListImpl
*list
, DWORD dwFlags
)
299 TRACE("(%p)->(flags=0x%08x)\n", list
, dwFlags
);
301 /* enumerate the folders */
302 if (dwFlags
& SHCONTF_FOLDERS
)
304 WCHAR wszDriveName
[] = {'A', ':', '\\', '\0'};
305 DWORD dwDrivemap
= get_drive_map();
309 while (ret
&& wszDriveName
[0]<='Z')
311 if(dwDrivemap
& 0x00000001L
)
312 ret
= AddToEnumList(list
, _ILCreateDrive(wszDriveName
));
314 dwDrivemap
= dwDrivemap
>> 1;
317 TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n",list
);
318 for (i
=0; i
<2; i
++) {
319 if (ret
&& !RegOpenKeyExW(i
== 0 ? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER
,
320 MyComputer_NameSpaceW
, 0, KEY_READ
, &hkey
))
330 size
= sizeof(iid
) / sizeof(iid
[0]);
331 r
= RegEnumKeyExW(hkey
, i
, iid
, &size
, 0, NULL
, NULL
, NULL
);
332 if (ERROR_SUCCESS
== r
)
334 /* FIXME: shell extensions, shouldn't the type be
336 ret
= AddToEnumList(list
, _ILCreateGuidFromStrW(iid
));
339 else if (ERROR_NO_MORE_ITEMS
== r
)
351 /**************************************************************************
352 * ISF_MyComputer_fnEnumObjects
354 static HRESULT WINAPI
ISF_MyComputer_fnEnumObjects (IShellFolder2
*iface
,
355 HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
*ppEnumIDList
)
357 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
358 IEnumIDListImpl
*list
;
360 TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This
,
361 hwndOwner
, dwFlags
, ppEnumIDList
);
363 if (!(list
= IEnumIDList_Constructor()))
364 return E_OUTOFMEMORY
;
365 CreateMyCompEnumList(list
, dwFlags
);
366 *ppEnumIDList
= &list
->IEnumIDList_iface
;
368 TRACE ("-- (%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
373 /**************************************************************************
374 * ISF_MyComputer_fnBindToObject
376 static HRESULT WINAPI
ISF_MyComputer_fnBindToObject (IShellFolder2
*iface
,
377 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
379 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
381 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This
,
382 pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
384 return SHELL32_BindToChild (This
->pidlRoot
, NULL
, pidl
, riid
, ppvOut
);
387 /**************************************************************************
388 * ISF_MyComputer_fnBindToStorage
390 static HRESULT WINAPI
ISF_MyComputer_fnBindToStorage (IShellFolder2
* iface
,
391 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
393 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
395 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
,
396 pidl
, pbcReserved
, shdebugstr_guid (riid
), ppvOut
);
402 /**************************************************************************
403 * ISF_MyComputer_fnCompareIDs
406 static HRESULT WINAPI
ISF_MyComputer_fnCompareIDs (IShellFolder2
*iface
,
407 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
409 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
412 TRACE ("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
413 hr
= SHELL32_CompareIDs(&This
->IShellFolder2_iface
, lParam
, pidl1
, pidl2
);
414 TRACE ("-- 0x%08x\n", hr
);
418 /**************************************************************************
419 * ISF_MyComputer_fnCreateViewObject
421 static HRESULT WINAPI
ISF_MyComputer_fnCreateViewObject (IShellFolder2
*iface
,
422 HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
424 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
425 LPSHELLVIEW pShellView
;
426 HRESULT hr
= E_INVALIDARG
;
428 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This
,
429 hwndOwner
, shdebugstr_guid (riid
), ppvOut
);
436 if (IsEqualIID (riid
, &IID_IDropTarget
))
438 WARN ("IDropTarget not implemented\n");
441 else if (IsEqualIID (riid
, &IID_IContextMenu
))
443 WARN ("IContextMenu not implemented\n");
446 else if (IsEqualIID (riid
, &IID_IShellView
))
448 pShellView
= IShellView_Constructor ((IShellFolder
*) iface
);
451 hr
= IShellView_QueryInterface (pShellView
, riid
, ppvOut
);
452 IShellView_Release (pShellView
);
455 TRACE ("-- (%p)->(interface=%p)\n", This
, ppvOut
);
459 /**************************************************************************
460 * ISF_MyComputer_fnGetAttributesOf
462 static HRESULT WINAPI
ISF_MyComputer_fnGetAttributesOf (IShellFolder2
* iface
,
463 UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
465 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
468 TRACE ("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
469 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
480 IShellFolder
*psfParent
= NULL
;
481 LPCITEMIDLIST rpidl
= NULL
;
483 hr
= SHBindToParent(This
->pidlRoot
, &IID_IShellFolder
, (LPVOID
*)&psfParent
, &rpidl
);
485 SHELL32_GetItemAttributes (psfParent
, rpidl
, rgfInOut
);
486 IShellFolder_Release(psfParent
);
489 while (cidl
> 0 && *apidl
) {
491 SHELL32_GetItemAttributes ((IShellFolder
*)&This
->IShellFolder2_iface
, *apidl
, rgfInOut
);
496 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
497 *rgfInOut
&= ~SFGAO_VALIDATE
;
499 TRACE ("-- result=0x%08x\n", *rgfInOut
);
503 /**************************************************************************
504 * ISF_MyComputer_fnGetUIObjectOf
507 * hwndOwner [in] Parent window for any output
508 * cidl [in] array size
509 * apidl [in] simple pidl array
510 * riid [in] Requested Interface
511 * prgfInOut [ ] reserved
512 * ppvObject [out] Resulting Interface
515 static HRESULT WINAPI
ISF_MyComputer_fnGetUIObjectOf (IShellFolder2
* iface
,
516 HWND hwndOwner
, UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
,
517 UINT
* prgfInOut
, LPVOID
* ppvOut
)
519 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
522 IUnknown
*pObj
= NULL
;
523 HRESULT hr
= E_INVALIDARG
;
525 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n", This
,
526 hwndOwner
, cidl
, apidl
, shdebugstr_guid (riid
), prgfInOut
, ppvOut
);
533 if (IsEqualIID (riid
, &IID_IContextMenu
) && (cidl
>= 1))
535 return ItemMenu_Constructor((IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
, riid
, ppvOut
);
537 else if (IsEqualIID (riid
, &IID_IDataObject
) && (cidl
>= 1))
539 pObj
= (LPUNKNOWN
) IDataObject_Constructor (hwndOwner
,
540 This
->pidlRoot
, apidl
, cidl
);
543 else if (IsEqualIID (riid
, &IID_IExtractIconA
) && (cidl
== 1))
545 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
546 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor (pidl
);
550 else if (IsEqualIID (riid
, &IID_IExtractIconW
) && (cidl
== 1))
552 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
553 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor (pidl
);
557 else if (IsEqualIID (riid
, &IID_IDropTarget
) && (cidl
>= 1))
559 hr
= IShellFolder2_QueryInterface (iface
, &IID_IDropTarget
,
562 else if ((IsEqualIID(riid
,&IID_IShellLinkW
) ||
563 IsEqualIID(riid
,&IID_IShellLinkA
)) && (cidl
== 1))
565 pidl
= ILCombine (This
->pidlRoot
, apidl
[0]);
566 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, &pObj
);
572 if (SUCCEEDED(hr
) && !pObj
)
576 TRACE ("(%p)->hr=0x%08x\n", This
, hr
);
580 /**************************************************************************
581 * ISF_MyComputer_fnGetDisplayNameOf
583 static HRESULT WINAPI
ISF_MyComputer_fnGetDisplayNameOf (IShellFolder2
*iface
,
584 LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
586 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
591 TRACE ("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
597 pszPath
= CoTaskMemAlloc((MAX_PATH
+1) * sizeof(WCHAR
));
599 return E_OUTOFMEMORY
;
605 /* parsing name like ::{...} */
608 SHELL32_GUIDToStringW(&CLSID_MyComputer
, &pszPath
[2]);
610 else if (_ILIsPidlSimple(pidl
))
612 /* take names of special folders only if its only this folder */
613 if (_ILIsSpecialFolder(pidl
))
617 clsid
= _ILGetGUIDPointer (pidl
);
620 if (GET_SHGDN_FOR (dwFlags
) & SHGDN_FORPARSING
)
622 static const WCHAR clsidW
[] =
623 { 'C','L','S','I','D','\\',0 };
624 static const WCHAR shellfolderW
[] =
625 { '\\','s','h','e','l','l','f','o','l','d','e','r',0 };
626 static const WCHAR wantsForParsingW
[] =
627 { 'W','a','n','t','s','F','o','r','P','a','r','s','i','n',
629 int bWantsForParsing
= FALSE
;
630 WCHAR szRegPath
[100];
634 * We can only get a filesystem path from a shellfolder
635 * if the value WantsFORPARSING exists in
636 * CLSID\\{...}\\shellfolder
637 * exception: the MyComputer folder has this keys not
638 * but like any filesystem backed
639 * folder it needs these behaviour
641 * Get the "WantsFORPARSING" flag from the registry
644 lstrcpyW (szRegPath
, clsidW
);
645 SHELL32_GUIDToStringW (clsid
, &szRegPath
[6]);
646 lstrcatW (szRegPath
, shellfolderW
);
647 r
= SHGetValueW (HKEY_CLASSES_ROOT
, szRegPath
,
648 wantsForParsingW
, NULL
, NULL
, NULL
);
649 if (r
== ERROR_SUCCESS
)
650 bWantsForParsing
= TRUE
;
652 if ((GET_SHGDN_RELATION (dwFlags
) == SHGDN_NORMAL
) &&
656 * We need the filesystem path to the destination folder
657 * Only the folder itself can know it
659 hr
= SHELL32_GetDisplayNameOfChild (iface
, pidl
,
660 dwFlags
, pszPath
, MAX_PATH
);
666 /* parsing name like ::{...} */
670 p
+= SHELL32_GUIDToStringW(&CLSID_MyComputer
, p
);
677 SHELL32_GUIDToStringW(clsid
, p
);
682 /* user friendly name */
683 HCR_GetClassNameW (clsid
, pszPath
, MAX_PATH
);
688 /* append my own path */
689 _ILSimpleGetTextW (pidl
, pszPath
, MAX_PATH
);
692 else if (_ILIsDrive(pidl
))
694 _ILSimpleGetTextW (pidl
, pszPath
, MAX_PATH
); /* append my own path */
696 /* long view "lw_name (C:)" */
697 if (!(dwFlags
& SHGDN_FORPARSING
))
699 DWORD dwVolumeSerialNumber
, dwMaximumComponetLength
, dwFileSystemFlags
;
700 WCHAR wszDrive
[18] = {0};
701 static const WCHAR wszOpenBracket
[] = {' ','(',0};
702 static const WCHAR wszCloseBracket
[] = {')',0};
704 GetVolumeInformationW (pszPath
, wszDrive
,
705 sizeof(wszDrive
)/sizeof(wszDrive
[0]) - 6,
706 &dwVolumeSerialNumber
,
707 &dwMaximumComponetLength
, &dwFileSystemFlags
, NULL
, 0);
708 strcatW (wszDrive
, wszOpenBracket
);
709 lstrcpynW (wszDrive
+ strlenW(wszDrive
), pszPath
, 3);
710 strcatW (wszDrive
, wszCloseBracket
);
711 strcpyW (pszPath
, wszDrive
);
716 /* Neither a shell namespace extension nor a drive letter. */
717 ERR("Wrong pidl type\n");
718 CoTaskMemFree(pszPath
);
724 /* Complex pidl. Let the child folder do the work */
725 hr
= SHELL32_GetDisplayNameOfChild(iface
, pidl
, dwFlags
, pszPath
, MAX_PATH
);
730 /* Win9x always returns ANSI strings, NT always returns Unicode strings */
731 if (GetVersion() & 0x80000000)
733 strRet
->uType
= STRRET_CSTR
;
734 if (!WideCharToMultiByte(CP_ACP
, 0, pszPath
, -1, strRet
->u
.cStr
, MAX_PATH
,
736 strRet
->u
.cStr
[0] = '\0';
737 CoTaskMemFree(pszPath
);
741 strRet
->uType
= STRRET_WSTR
;
742 strRet
->u
.pOleStr
= pszPath
;
746 CoTaskMemFree(pszPath
);
748 TRACE ("-- (%p)->(%s)\n", This
, strRet
->uType
== STRRET_CSTR
? strRet
->u
.cStr
: debugstr_w(strRet
->u
.pOleStr
));
752 /**************************************************************************
753 * ISF_MyComputer_fnSetNameOf
754 * Changes the name of a file object or subfolder, possibly changing its item
755 * identifier in the process.
758 * hwndOwner [in] Owner window for output
759 * pidl [in] simple pidl of item to change
760 * lpszName [in] the items new display name
761 * dwFlags [in] SHGNO formatting flags
762 * ppidlOut [out] simple pidl returned
764 static HRESULT WINAPI
ISF_MyComputer_fnSetNameOf (
765 IShellFolder2
* iface
, HWND hwndOwner
, LPCITEMIDLIST pidl
,
766 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
768 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
769 FIXME ("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
,
770 hwndOwner
, pidl
, debugstr_w (lpName
), dwFlags
, pPidlOut
);
774 static HRESULT WINAPI
ISF_MyComputer_fnGetDefaultSearchGUID (
775 IShellFolder2
* iface
, GUID
* pguid
)
777 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
778 FIXME ("(%p)\n", This
);
781 static HRESULT WINAPI
ISF_MyComputer_fnEnumSearches (
782 IShellFolder2
* iface
, IEnumExtraSearch
** ppenum
)
784 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
785 FIXME ("(%p)\n", This
);
788 static HRESULT WINAPI
ISF_MyComputer_fnGetDefaultColumn (
789 IShellFolder2
*iface
, DWORD dwRes
, ULONG
*pSort
, ULONG
*pDisplay
)
791 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
793 TRACE ("(%p)\n", This
);
801 static HRESULT WINAPI
ISF_MyComputer_fnGetDefaultColumnState (
802 IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
804 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
806 TRACE ("(%p)->(%d %p)\n", This
, iColumn
, pcsFlags
);
808 if (!pcsFlags
|| iColumn
>= MYCOMPUTERSHELLVIEWCOLUMNS
)
811 *pcsFlags
= mycomputer_header
[iColumn
].pcsFlags
;
816 static HRESULT WINAPI
ISF_MyComputer_fnGetDetailsEx (IShellFolder2
* iface
,
817 LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
819 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
820 FIXME ("(%p)\n", This
);
824 /* FIXME: drive size >4GB is rolling over */
825 static HRESULT WINAPI
ISF_MyComputer_fnGetDetailsOf (IShellFolder2
*iface
,
826 LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
*psd
)
828 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
829 char szPath
[MAX_PATH
];
830 ULARGE_INTEGER ulBytes
;
833 TRACE ("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
835 if (!psd
|| iColumn
>= MYCOMPUTERSHELLVIEWCOLUMNS
)
839 return SHELL32_GetColumnDetails(mycomputer_header
, iColumn
, psd
);
841 psd
->str
.u
.cStr
[0] = 0;
842 psd
->str
.uType
= STRRET_CSTR
;
847 hr
= IShellFolder2_GetDisplayNameOf (iface
, pidl
,
848 SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
851 _ILGetFileType (pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
853 case 2: /* total size */
854 if (_ILIsDrive (pidl
))
856 _ILSimpleGetText (pidl
, szPath
, MAX_PATH
);
857 GetDiskFreeSpaceExA (szPath
, NULL
, &ulBytes
, NULL
);
858 StrFormatByteSizeA (ulBytes
.u
.LowPart
, psd
->str
.u
.cStr
, MAX_PATH
);
861 case 3: /* free size */
862 if (_ILIsDrive (pidl
))
864 _ILSimpleGetText (pidl
, szPath
, MAX_PATH
);
865 GetDiskFreeSpaceExA (szPath
, &ulBytes
, NULL
, NULL
);
866 StrFormatByteSizeA (ulBytes
.u
.LowPart
, psd
->str
.u
.cStr
, MAX_PATH
);
874 static HRESULT WINAPI
ISF_MyComputer_fnMapColumnToSCID (
875 IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
877 IMyComputerFolderImpl
*This
= impl_from_IShellFolder2(iface
);
878 FIXME ("(%p)\n", This
);
882 static const IShellFolder2Vtbl vt_ShellFolder2
=
884 ISF_MyComputer_fnQueryInterface
,
885 ISF_MyComputer_fnAddRef
,
886 ISF_MyComputer_fnRelease
,
887 ISF_MyComputer_fnParseDisplayName
,
888 ISF_MyComputer_fnEnumObjects
,
889 ISF_MyComputer_fnBindToObject
,
890 ISF_MyComputer_fnBindToStorage
,
891 ISF_MyComputer_fnCompareIDs
,
892 ISF_MyComputer_fnCreateViewObject
,
893 ISF_MyComputer_fnGetAttributesOf
,
894 ISF_MyComputer_fnGetUIObjectOf
,
895 ISF_MyComputer_fnGetDisplayNameOf
,
896 ISF_MyComputer_fnSetNameOf
,
898 ISF_MyComputer_fnGetDefaultSearchGUID
,
899 ISF_MyComputer_fnEnumSearches
,
900 ISF_MyComputer_fnGetDefaultColumn
,
901 ISF_MyComputer_fnGetDefaultColumnState
,
902 ISF_MyComputer_fnGetDetailsEx
,
903 ISF_MyComputer_fnGetDetailsOf
,
904 ISF_MyComputer_fnMapColumnToSCID
907 /************************************************************************
908 * IMCFldr_PersistFolder2_QueryInterface
910 static HRESULT WINAPI
IMCFldr_PersistFolder2_QueryInterface (
911 IPersistFolder2
* iface
, REFIID iid
, LPVOID
* ppvObj
)
913 IMyComputerFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
914 TRACE ("(%p)\n", This
);
915 return IShellFolder2_QueryInterface (&This
->IShellFolder2_iface
, iid
, ppvObj
);
918 /************************************************************************
919 * IMCFldr_PersistFolder2_AddRef
921 static ULONG WINAPI
IMCFldr_PersistFolder2_AddRef (IPersistFolder2
* iface
)
923 IMyComputerFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
924 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
925 return IShellFolder2_AddRef (&This
->IShellFolder2_iface
);
928 /************************************************************************
929 * ISFPersistFolder_Release
931 static ULONG WINAPI
IMCFldr_PersistFolder2_Release (IPersistFolder2
* iface
)
933 IMyComputerFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
934 TRACE ("(%p)->(count=%u)\n", This
, This
->ref
);
935 return IShellFolder2_Release (&This
->IShellFolder2_iface
);
938 /************************************************************************
939 * IMCFldr_PersistFolder2_GetClassID
941 static HRESULT WINAPI
IMCFldr_PersistFolder2_GetClassID (
942 IPersistFolder2
* iface
, CLSID
* lpClassId
)
944 IMyComputerFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
946 TRACE ("(%p)\n", This
);
950 *lpClassId
= CLSID_MyComputer
;
955 /************************************************************************
956 * IMCFldr_PersistFolder2_Initialize
958 * NOTES: it makes no sense to change the pidl
960 static HRESULT WINAPI
IMCFldr_PersistFolder2_Initialize (
961 IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
963 IMyComputerFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
964 TRACE ("(%p)->(%p)\n", This
, pidl
);
968 /**************************************************************************
969 * IPersistFolder2_fnGetCurFolder
971 static HRESULT WINAPI
IMCFldr_PersistFolder2_GetCurFolder (
972 IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
974 IMyComputerFolderImpl
*This
= impl_from_IPersistFolder2(iface
);
976 TRACE ("(%p)->(%p)\n", This
, pidl
);
980 *pidl
= ILClone (This
->pidlRoot
);
984 static const IPersistFolder2Vtbl vt_PersistFolder2
=
986 IMCFldr_PersistFolder2_QueryInterface
,
987 IMCFldr_PersistFolder2_AddRef
,
988 IMCFldr_PersistFolder2_Release
,
989 IMCFldr_PersistFolder2_GetClassID
,
990 IMCFldr_PersistFolder2_Initialize
,
991 IMCFldr_PersistFolder2_GetCurFolder