4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998, 1999 Juergen Schmied
7 * IShellFolder2 and related interfaces
15 #include "debugtools.h"
23 #include "wine/winestring.h"
24 #include "wine/obj_base.h"
25 #include "wine/obj_dragdrop.h"
26 #include "wine/obj_shellfolder.h"
27 #include "wine/undocshell.h"
28 #include "shell32_main.h"
34 #include "shellfolder.h"
35 #include "wine/obj_queryassociations.h"
37 DEFAULT_DEBUG_CHANNEL(shell)
40 /***************************************************************************
41 * debughelper: print out the return adress
42 * helps especially to track down unbalanced AddRef/Release
47 #define _CALL_TRACE TRACE("called from: 0x%08x\n", *( ((UINT*)&iface)-1 ));
61 /***************************************************************************
62 * GetNextElement (internal function)
64 * gets a part of a string till the first backslash
67 * pszNext [IN] string to get the element from
68 * pszOut [IN] pointer to buffer whitch receives string
69 * dwOut [IN] length of pszOut
72 * LPSTR pointer to first, not yet parsed char
75 static LPCWSTR GetNextElementW(LPCWSTR pszNext,LPWSTR pszOut,DWORD dwOut)
76 { LPCWSTR pszTail = pszNext;
78 TRACE("(%s %p 0x%08lx)\n",debugstr_w(pszNext),pszOut,dwOut);
82 if(!pszNext || !*pszNext)
85 while(*pszTail && (*pszTail != (WCHAR)'\\'))
88 dwCopy = (WCHAR*)pszTail - (WCHAR*)pszNext + 1;
89 lstrcpynW(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
96 TRACE("--(%s %s 0x%08lx %p)\n",debugstr_w(pszNext),debugstr_w(pszOut),dwOut,pszTail);
100 static HRESULT SHELL32_ParseNextElement(
103 LPITEMIDLIST * pidlInOut,
106 DWORD *pdwAttributes)
108 HRESULT hr = E_OUTOFMEMORY;
109 LPITEMIDLIST pidlOut, pidlTemp = NULL;
110 IShellFolder *psfChild;
112 TRACE("(%p, %p, %s)\n",psf, pidlInOut ? *pidlInOut : NULL, debugstr_w(szNext));
115 /* get the shellfolder for the child pidl and let it analyse further */
116 hr = IShellFolder_BindToObject(psf, *pidlInOut, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
120 hr = IShellFolder_ParseDisplayName(psfChild, hwndOwner, NULL, szNext, pEaten, &pidlOut, pdwAttributes);
121 IShellFolder_Release(psfChild);
123 pidlTemp = ILCombine(*pidlInOut, pidlOut);
130 *pidlInOut = pidlTemp;
132 TRACE("-- pidl=%p ret=0x%08lx\n", pidlInOut? *pidlInOut: NULL, hr);
136 /***********************************************************************
137 * SHELL32_CoCreateInitSF
139 * creates a initialized shell folder
141 static HRESULT SHELL32_CoCreateInitSF (
142 LPITEMIDLIST pidlRoot,
143 LPITEMIDLIST pidlChild,
149 LPITEMIDLIST absPidl;
150 IShellFolder2 *pShellFolder;
151 IPersistFolder *pPersistFolder;
153 TRACE("%p %p\n", pidlRoot, pidlChild);
157 /* we have to ask first for IPersistFolder, some special folders are expecting this */
158 hr = SHCoCreateInstance(NULL, clsid, NULL, &IID_IPersistFolder, (LPVOID*)&pPersistFolder);
161 hr = IPersistFolder_QueryInterface(pPersistFolder, iid, (LPVOID*)&pShellFolder);
164 absPidl = ILCombine (pidlRoot, pidlChild);
165 hr = IPersistFolder_Initialize(pPersistFolder, absPidl);
166 IPersistFolder_Release(pPersistFolder);
168 *ppvOut = pShellFolder;
172 TRACE("-- ret=0x%08lx\n", hr);
176 static HRESULT SHELL32_GetDisplayNameOfChild(
183 LPITEMIDLIST pidlFirst, pidlNext;
184 IShellFolder2 * psfChild;
185 HRESULT hr = E_OUTOFMEMORY;
188 TRACE("(%p)->(pidl=%p 0x%08lx %p 0x%08lx)\n",psf,pidl,dwFlags,szOut, dwOutLen);
191 if ((pidlFirst = ILCloneFirst(pidl)))
193 hr = IShellFolder_BindToObject(psf, pidlFirst, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
196 pidlNext = ILGetNext(pidl);
198 hr = IShellFolder_GetDisplayNameOf(psfChild, pidlNext, dwFlags | SHGDN_INFOLDER, &strTemp);
201 hr = StrRetToStrNA(szOut, dwOutLen, &strTemp, pidlNext);
204 IShellFolder_Release(psfChild);
209 TRACE("-- ret=0x%08lx %s\n", hr, szOut);
214 /***********************************************************************
215 * SHELL32_GetItemAttributes
219 * folder: 0xE0000177 FILESYSTEM | HASSUBFOLDER | FOLDER
220 * file: 0x40000177 FILESYSTEM
221 * drive: 0xf0000144 FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR
222 * mycomputer: 0xb0000154 HASSUBFOLDER | FOLDER | FILESYSANCESTOR
223 * (seems to be default for shell extensions if no registry entry exists)
225 * This functions does not set flags!! It only resets flags when nessesary.
227 static HRESULT SHELL32_GetItemAttributes(
230 LPDWORD pdwAttributes)
235 TRACE("0x%08lx\n", *pdwAttributes);
237 if (*pdwAttributes & (0xcff3fe88))
238 WARN("attribute 0x%08lx not implemented\n", *pdwAttributes);
239 *pdwAttributes &= ~SFGAO_LINK; /* FIXME: for native filedialogs */
241 if (_ILIsDrive(pidl))
243 *pdwAttributes &= 0xf0000144;
245 else if ((clsid=_ILGetGUIDPointer(pidl)))
247 if (HCR_GetFolderAttributes(clsid, &dwAttributes))
249 *pdwAttributes &= dwAttributes;
253 *pdwAttributes &= 0xb0000154;
256 else if (_ILGetDataPointer(pidl))
258 dwAttributes = _ILGetFileAttributes(pidl, NULL, 0);
259 *pdwAttributes &= ~SFGAO_FILESYSANCESTOR;
261 if(( SFGAO_FOLDER & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
262 *pdwAttributes &= ~(SFGAO_FOLDER|SFGAO_HASSUBFOLDER);
264 if(( SFGAO_HIDDEN & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_HIDDEN))
265 *pdwAttributes &= ~SFGAO_HIDDEN;
267 if(( SFGAO_READONLY & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_READONLY))
268 *pdwAttributes &= ~SFGAO_READONLY;
272 *pdwAttributes &= 0xb0000154;
274 TRACE("-- 0x%08lx\n", *pdwAttributes);
278 /***********************************************************************
279 * IShellFolder implementation
284 ICOM_VFIELD(IUnknown);
286 ICOM_VTABLE(IShellFolder2)* lpvtblShellFolder;
287 ICOM_VTABLE(IPersistFolder2)* lpvtblPersistFolder2;
288 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
289 ICOM_VTABLE(ISFHelper)* lpvtblSFHelper;
291 IUnknown *pUnkOuter; /* used for aggregation */
296 LPITEMIDLIST absPidl; /* complete pidl */
298 UINT cfShellIDList; /* clipboardformat for IDropTarget */
299 BOOL fAcceptFmt; /* flag for pending Drop */
302 static struct ICOM_VTABLE(IUnknown) unkvt;
303 static struct ICOM_VTABLE(IShellFolder2) sfvt;
304 static struct ICOM_VTABLE(IPersistFolder2) psfvt;
305 static struct ICOM_VTABLE(IDropTarget) dtvt;
306 static struct ICOM_VTABLE(ISFHelper) shvt;
308 static IShellFolder * ISF_MyComputer_Constructor(void);
310 #define _IShellFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblShellFolder)))
311 #define _ICOM_THIS_From_IShellFolder2(class, name) class* This = (class*)(((char*)name)-_IShellFolder2_Offset);
313 #define _IPersistFolder_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder2)))
314 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder_Offset);
316 #define _IDropTarget_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblDropTarget)))
317 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
319 #define _ISFHelper_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblSFHelper)))
320 #define _ICOM_THIS_From_ISFHelper(class, name) class* This = (class*)(((char*)name)-_ISFHelper_Offset);
322 converts This to a interface pointer
324 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
325 #define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder)
326 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder)
327 #define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder2)
328 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder2)
329 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder2)
330 #define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget)
331 #define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper)
332 /**************************************************************************
333 * registers clipboardformat once
335 static void SF_RegisterClipFmt (IGenericSFImpl * This)
337 TRACE("(%p)\n", This);
339 if (!This->cfShellIDList)
341 This->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
345 /**************************************************************************
346 * we need a seperate IUnknown to handle aggregation
349 static HRESULT WINAPI IUnknown_fnQueryInterface(
354 ICOM_THIS(IGenericSFImpl, iface);
357 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
361 if(IsEqualIID(riid, &IID_IUnknown)) *ppvObj = _IUnknown_(This);
362 else if(IsEqualIID(riid, &IID_IShellFolder)) *ppvObj = _IShellFolder_(This);
363 else if(IsEqualIID(riid, &IID_IShellFolder2)) *ppvObj = _IShellFolder_(This);
364 else if(IsEqualIID(riid, &IID_IPersist)) *ppvObj = _IPersist_(This);
365 else if(IsEqualIID(riid, &IID_IPersistFolder)) *ppvObj = _IPersistFolder_(This);
366 else if(IsEqualIID(riid, &IID_IPersistFolder2)) *ppvObj = _IPersistFolder2_(This);
367 else if(IsEqualIID(riid, &IID_ISFHelper)) *ppvObj = _ISFHelper_(This);
368 else if(IsEqualIID(riid, &IID_IDropTarget))
370 *ppvObj = _IDropTarget_(This);
371 SF_RegisterClipFmt(This);
376 IUnknown_AddRef((IUnknown*)(*ppvObj));
377 TRACE("-- Interface = %p\n", *ppvObj);
380 TRACE("-- Interface: E_NOINTERFACE\n");
381 return E_NOINTERFACE;
384 static ULONG WINAPI IUnknown_fnAddRef(IUnknown * iface)
386 ICOM_THIS(IGenericSFImpl, iface);
389 TRACE("(%p)->(count=%lu)\n",This,This->ref);
392 return ++(This->ref);
395 static ULONG WINAPI IUnknown_fnRelease(IUnknown * iface)
397 ICOM_THIS(IGenericSFImpl, iface);
400 TRACE("(%p)->(count=%lu)\n",This,This->ref);
405 TRACE("-- destroying IShellFolder(%p)\n",This);
407 if (pdesktopfolder == _IShellFolder_(This))
410 TRACE("-- destroyed IShellFolder(%p) was Desktopfolder\n",This);
412 if(This->absPidl) SHFree(This->absPidl);
413 if(This->sMyPath) SHFree(This->sMyPath);
414 HeapFree(GetProcessHeap(),0,This);
420 static ICOM_VTABLE(IUnknown) unkvt =
422 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
423 IUnknown_fnQueryInterface,
428 static shvheader GenericSFHeader [] =
430 { IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
431 { IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
432 { IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
433 { IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12 },
434 { IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5 }
436 #define GENERICSHELLVIEWCOLUMNS 5
438 /**************************************************************************
439 * IShellFolder_Constructor
442 * creating undocumented ShellFS_Folder as part of an aggregation
443 * {F3364BA0-65B9-11CE-A9BA-00AA004AE837}
446 * when pUnkOuter = 0 then rrid = IID_IShellFolder is returned
448 HRESULT IFSFolder_Constructor(
449 IUnknown * pUnkOuter,
456 TRACE("unkOut=%p riid=%s\n",pUnkOuter, debugstr_guid(riid));
458 if(pUnkOuter && ! IsEqualIID(riid, &IID_IUnknown))
460 hr = CLASS_E_NOAGGREGATION; /* forbidden by definition */
464 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
468 ICOM_VTBL(sf)=&unkvt;
469 sf->lpvtblShellFolder=&sfvt;
470 sf->lpvtblPersistFolder2=&psfvt;
471 sf->lpvtblDropTarget=&dtvt;
472 sf->lpvtblSFHelper=&shvt;
474 sf->pclsid = (CLSID*)&CLSID_SFFile;
475 sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_(sf);
476 *ppv = _IUnknown_(sf);
487 /**************************************************************************
488 * IShellFolder_Constructor
491 * THIS points to the parent folder
494 IShellFolder * IShellFolder_Constructor(
495 IShellFolder2 * iface,
501 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
503 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
506 ICOM_VTBL(sf)=&unkvt;
507 sf->lpvtblShellFolder=&sfvt;
508 sf->lpvtblPersistFolder2=&psfvt;
509 sf->lpvtblDropTarget=&dtvt;
510 sf->lpvtblSFHelper=&shvt;
512 sf->pclsid = (CLSID*)&CLSID_SFFile;
513 sf->pUnkOuter = _IUnknown_(sf);
515 TRACE("(%p)->(parent=%p, pidl=%p)\n",sf,This, pidl);
518 if(pidl && iface) /* do we have a pidl? */
522 sf->absPidl = ILCombine(This->absPidl, pidl); /* build a absolute pidl */
524 if (!_ILIsSpecialFolder(pidl)) /* only file system paths */
526 if(This->sMyPath) /* get the size of the parents path */
528 dwSize += strlen(This->sMyPath) ;
529 TRACE("-- (%p)->(parent's path=%s)\n",sf, debugstr_a(This->sMyPath));
532 dwSize += _ILSimpleGetText(pidl,NULL,0); /* add the size of our name*/
533 sf->sMyPath = SHAlloc(dwSize + 2); /* '\0' and backslash */
535 if(!sf->sMyPath) return NULL;
538 if(This->sMyPath) /* if the parent has a path, get it*/
540 strcpy(sf->sMyPath, This->sMyPath);
541 PathAddBackslashA (sf->sMyPath);
544 len = strlen(sf->sMyPath);
545 _ILSimpleGetText(pidl, sf->sMyPath + len, dwSize+2 - len);
548 TRACE("-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->absPidl,debugstr_a(sf->sMyPath));
554 return _IShellFolder_(sf);
557 /**************************************************************************
558 * IShellFolder_fnQueryInterface
561 * REFIID riid [in ] Requested InterfaceID
562 * LPVOID* ppvObject [out] Interface* to hold the result
564 static HRESULT WINAPI IShellFolder_fnQueryInterface(
565 IShellFolder2 * iface,
569 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
572 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
574 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObj);
577 /**************************************************************************
578 * IShellFolder_AddRef
581 static ULONG WINAPI IShellFolder_fnAddRef(IShellFolder2 * iface)
583 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
586 TRACE("(%p)->(count=%lu)\n",This,This->ref);
588 return IUnknown_AddRef(This->pUnkOuter);
591 /**************************************************************************
592 * IShellFolder_fnRelease
594 static ULONG WINAPI IShellFolder_fnRelease(IShellFolder2 * iface)
596 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
599 TRACE("(%p)->(count=%lu)\n",This,This->ref);
601 return IUnknown_Release(This->pUnkOuter);
604 /**************************************************************************
605 * IShellFolder_fnParseDisplayName
607 * HWND hwndOwner, //[in ] Parent window for any message's
608 * LPBC pbc, //[in ] reserved
609 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
610 * ULONG* pchEaten, //[out] (unicode) characters processed
611 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
612 * ULONG* pdwAttributes //[out] items attributes
615 * every folder trys to parse only it's own (the leftmost) pidl and creates a
616 * subfolder to evaluate the remaining parts
617 * now we can parse into namespaces implemented by shell extensions
619 * behaviour on win98: lpszDisplayName=NULL -> chrash
620 * lpszDisplayName="" -> returns mycoputer-pidl
623 * pdwAttributes: not set
624 * pchEaten: not set like in windows
626 static HRESULT WINAPI IShellFolder_fnParseDisplayName(
627 IShellFolder2 * iface,
630 LPOLESTR lpszDisplayName,
633 DWORD *pdwAttributes)
635 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
637 HRESULT hr = E_OUTOFMEMORY;
639 WCHAR szElement[MAX_PATH];
640 CHAR szTempA[MAX_PATH], szPath[MAX_PATH];
641 LPITEMIDLIST pidlTemp=NULL;
643 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
644 This,hwndOwner,pbcReserved,lpszDisplayName,
645 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
647 if (!lpszDisplayName || !ppidl) return E_INVALIDARG;
649 if (pchEaten) *pchEaten = 0; /* strange but like the original */
651 if (*lpszDisplayName)
653 /* get the next element */
654 szNext = GetNextElementW(lpszDisplayName, szElement, MAX_PATH);
656 /* build the full pathname to the element */
657 lstrcpynWtoA(szTempA, szElement, lstrlenW(szElement) + 1);
658 strcpy(szPath, This->sMyPath);
659 PathAddBackslashA(szPath);
660 strcat(szPath, szTempA);
663 pidlTemp = SHSimpleIDListFromPathA(szPath);
667 /* try to analyse the next element */
668 if (szNext && *szNext)
670 hr = SHELL32_ParseNextElement(hwndOwner, iface, &pidlTemp, (LPOLESTR)szNext, pchEaten, pdwAttributes);
674 if (pdwAttributes && *pdwAttributes)
676 SHELL32_GetItemAttributes(_IShellFolder_(This), pidlTemp, pdwAttributes);
677 /* WIN32_FIND_DATAA fd;
678 SHGetDataFromIDListA(_IShellFolder_(This), pidlTemp, SHGDFIL_FINDDATA, &fd, sizeof(fd));
679 if (!(FILE_ATTRIBUTE_DIRECTORY & fd.dwFileAttributes))
680 *pdwAttributes &= ~SFGAO_FOLDER;
681 if (FILE_ATTRIBUTE_READONLY & fd.dwFileAttributes)
682 *pdwAttributes &= ~(SFGAO_CANDELETE|SFGAO_CANMOVE|SFGAO_CANRENAME );
692 TRACE("(%p)->(-- pidl=%p ret=0x%08lx)\n", This, ppidl? *ppidl:0, hr);
697 /**************************************************************************
698 * IShellFolder_fnEnumObjects
700 * HWND hwndOwner, //[in ] Parent Window
701 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
702 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
704 static HRESULT WINAPI IShellFolder_fnEnumObjects(
705 IShellFolder2 * iface,
708 LPENUMIDLIST* ppEnumIDList)
710 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
712 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
714 *ppEnumIDList = NULL;
715 *ppEnumIDList = IEnumIDList_Constructor (This->sMyPath, dwFlags, EIDL_FILE);
717 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
719 if(!*ppEnumIDList) return E_OUTOFMEMORY;
724 /**************************************************************************
725 * IShellFolder_fnBindToObject
727 * LPCITEMIDLIST pidl, //[in ] relative pidl to open
728 * LPBC pbc, //[in ] reserved
729 * REFIID riid, //[in ] Initial Interface
730 * LPVOID* ppvObject //[out] Interface*
732 static HRESULT WINAPI IShellFolder_fnBindToObject( IShellFolder2 * iface, LPCITEMIDLIST pidl,
733 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
735 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
737 IShellFolder *pShellFolder, *pSubFolder;
738 IPersistFolder *pPersistFolder;
739 LPITEMIDLIST absPidl;
741 TRACE("(%p)->(pidl=%p,%p,\n\tIID:\t%s,%p)\n",This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
743 if(!pidl || !ppvOut) return E_INVALIDARG;
747 if ((iid=_ILGetGUIDPointer(pidl)))
749 /* we have to create a alien folder */
750 if ( SUCCEEDED(SHCoCreateInstance(NULL, iid, NULL, riid, (LPVOID*)&pShellFolder))
751 && SUCCEEDED(IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder, (LPVOID*)&pPersistFolder)))
753 absPidl = ILCombine (This->absPidl, pidl);
754 IPersistFolder_Initialize(pPersistFolder, absPidl);
755 IPersistFolder_Release(pPersistFolder);
763 else if(_ILIsFolder(pidl))
765 LPITEMIDLIST pidltemp = ILCloneFirst(pidl);
766 pShellFolder = IShellFolder_Constructor(iface, pidltemp);
771 ERR("can't bind to a file\n");
775 if (_ILIsPidlSimple(pidl))
777 *ppvOut = pShellFolder;
781 IShellFolder_BindToObject(pShellFolder, ILGetNext(pidl), NULL, &IID_IShellFolder, (LPVOID)&pSubFolder);
782 IShellFolder_Release(pShellFolder);
783 *ppvOut = pSubFolder;
786 TRACE("-- (%p) returning (%p)\n",This, *ppvOut);
791 /**************************************************************************
792 * IShellFolder_fnBindToStorage
794 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
795 * LPBC pbc, //[in ] reserved
796 * REFIID riid, //[in ] Initial storage interface
797 * LPVOID* ppvObject //[out] Interface* returned
799 static HRESULT WINAPI IShellFolder_fnBindToStorage(
800 IShellFolder2 * iface,
806 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
808 FIXME("(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",
809 This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
815 /**************************************************************************
816 * IShellFolder_fnCompareIDs
819 * LPARAM lParam, //[in ] Column?
820 * LPCITEMIDLIST pidl1, //[in ] simple pidl
821 * LPCITEMIDLIST pidl2) //[in ] simple pidl
824 * Special case - If one of the items is a Path and the other is a File,
825 * always make the Path come before the File.
828 * use SCODE_CODE() on the return value to get the result
831 static HRESULT WINAPI IShellFolder_fnCompareIDs(
832 IShellFolder2 * iface,
837 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
839 CHAR szTemp1[MAX_PATH];
840 CHAR szTemp2[MAX_PATH];
843 HRESULT hr = E_OUTOFMEMORY;
844 LPCITEMIDLIST pidlTemp;
847 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",This,lParam,pidl1,pidl2);
851 if (!pidl1 && !pidl2)
853 hr = ResultFromShort(0);
857 hr = ResultFromShort(-1);
861 hr = ResultFromShort(1);
866 pd1 = _ILGetDataPointer(pidl1);
867 pd2 = _ILGetDataPointer(pidl2);
869 /* compate the types. sort order is the PT_* constant */
870 pt1 = ( pd1 ? pd1->type: PT_DESKTOP);
871 pt2 = ( pd2 ? pd2->type: PT_DESKTOP);
875 hr = ResultFromShort(pt1-pt2);
877 else /* same type of pidl */
879 _ILSimpleGetText(pidl1, szTemp1, MAX_PATH);
880 _ILSimpleGetText(pidl2, szTemp2, MAX_PATH);
881 nReturn = strcasecmp(szTemp1, szTemp2);
883 if (nReturn == 0) /* first pidl different ? */
885 pidl1 = ILGetNext(pidl1);
887 if (pidl1 && pidl1->mkid.cb) /* go deeper? */
889 pidlTemp = ILCloneFirst(pidl1);
890 pidl2 = ILGetNext(pidl2);
892 hr = IShellFolder_BindToObject(iface, pidlTemp, NULL, &IID_IShellFolder, (LPVOID*)&psf);
895 nReturn = IShellFolder_CompareIDs(psf, 0, pidl1, pidl2);
896 IShellFolder_Release(psf);
897 hr = ResultFromShort(nReturn);
903 hr = ResultFromShort(nReturn); /* two equal simple pidls */
908 hr = ResultFromShort(nReturn); /* two different simple pidls */
913 TRACE("-- res=0x%08lx\n", hr);
917 /**************************************************************************
918 * IShellFolder_fnCreateViewObject
920 static HRESULT WINAPI IShellFolder_fnCreateViewObject(
921 IShellFolder2 * iface,
926 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
928 LPSHELLVIEW pShellView;
929 HRESULT hr = E_INVALIDARG;
931 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,debugstr_guid(riid),ppvOut);
937 if(IsEqualIID(riid, &IID_IDropTarget))
939 hr = IShellFolder_QueryInterface(iface, &IID_IDropTarget, ppvOut);
941 else if(IsEqualIID(riid, &IID_IContextMenu))
943 FIXME("IContextMenu not implemented\n");
946 else if(IsEqualIID(riid, &IID_IShellView))
948 pShellView = IShellView_Constructor((IShellFolder*)iface);
951 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
952 IShellView_Release(pShellView);
956 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
960 /**************************************************************************
961 * IShellFolder_fnGetAttributesOf
964 * UINT cidl, //[in ] num elements in pidl array
965 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
966 * ULONG* rgfInOut) //[out] result array
969 static HRESULT WINAPI IShellFolder_fnGetAttributesOf(
970 IShellFolder2 * iface,
972 LPCITEMIDLIST *apidl,
975 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
979 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n",This,cidl,apidl,*rgfInOut);
981 if ( (!cidl) || (!apidl) || (!rgfInOut))
984 while (cidl > 0 && *apidl)
987 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
992 TRACE("-- result=0x%08lx\n",*rgfInOut);
996 /**************************************************************************
997 * IShellFolder_fnGetUIObjectOf
1000 * HWND hwndOwner, //[in ] Parent window for any output
1001 * UINT cidl, //[in ] array size
1002 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
1003 * REFIID riid, //[in ] Requested Interface
1004 * UINT* prgfInOut, //[ ] reserved
1005 * LPVOID* ppvObject) //[out] Resulting Interface
1008 * This function gets asked to return "view objects" for one or more (multiple select)
1010 * The viewobject typically is an COM object with one of the following interfaces:
1011 * IExtractIcon,IDataObject,IContextMenu
1012 * In order to support icon positions in the default Listview your DataObject
1013 * must implement the SetData method (in addition to GetData :) - the shell passes
1014 * a barely documented "Icon positions" structure to SetData when the drag starts,
1015 * and GetData's it if the drop is in another explorer window that needs the positions.
1017 static HRESULT WINAPI IShellFolder_fnGetUIObjectOf(
1018 IShellFolder2 * iface,
1021 LPCITEMIDLIST * apidl,
1026 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1029 IUnknown* pObj = NULL;
1030 HRESULT hr = E_INVALIDARG;
1032 TRACE("(%p)->(0x%04x,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
1033 This,hwndOwner,cidl,apidl,debugstr_guid(riid),prgfInOut,ppvOut);
1039 if(IsEqualIID(riid, &IID_IContextMenu) && (cidl >= 1))
1041 pObj = (LPUNKNOWN)ISvItemCm_Constructor((IShellFolder*)iface, This->absPidl, apidl, cidl);
1044 else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1))
1046 pObj = (LPUNKNOWN)IDataObject_Constructor (hwndOwner, This->absPidl, apidl, cidl);
1049 else if (IsEqualIID(riid, &IID_IExtractIconA) && (cidl == 1))
1051 pidl = ILCombine(This->absPidl,apidl[0]);
1052 pObj = (LPUNKNOWN)IExtractIconA_Constructor( pidl );
1056 else if (IsEqualIID(riid, &IID_IDropTarget) && (cidl >= 1))
1058 hr = IShellFolder_QueryInterface(iface, &IID_IDropTarget, (LPVOID*)&pObj);
1070 TRACE("(%p)->hr=0x%08lx\n",This, hr);
1074 /**************************************************************************
1075 * IShellFolder_fnGetDisplayNameOf
1076 * Retrieves the display name for the specified file object or subfolder
1079 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
1080 * DWORD dwFlags, //[in ] SHGNO formatting flags
1081 * LPSTRRET lpName) //[out] Returned display name
1084 * if the name is in the pidl the ret value should be a STRRET_OFFSET
1086 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
1087 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
1089 static HRESULT WINAPI IShellFolder_fnGetDisplayNameOf(
1090 IShellFolder2 * iface,
1095 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1097 CHAR szPath[MAX_PATH]= "";
1101 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,strRet);
1104 if(!pidl || !strRet) return E_INVALIDARG;
1106 bSimplePidl = _ILIsPidlSimple(pidl);
1108 /* take names of special folders only if its only this folder */
1109 if (_ILIsSpecialFolder(pidl))
1113 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
1118 if (!(dwFlags & SHGDN_INFOLDER) && (dwFlags & SHGDN_FORPARSING) && This->sMyPath)
1120 strcpy (szPath, This->sMyPath); /* get path to root*/
1121 PathAddBackslashA(szPath);
1122 len = strlen(szPath);
1124 _ILSimpleGetText(pidl, szPath + len, MAX_PATH - len); /* append my own path */
1127 if ( (dwFlags & SHGDN_FORPARSING) && !bSimplePidl) /* go deeper if needed */
1129 PathAddBackslashA(szPath);
1130 len = strlen(szPath);
1132 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, szPath + len, MAX_PATH - len)))
1133 return E_OUTOFMEMORY;
1135 strRet->uType = STRRET_CSTRA;
1136 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
1138 TRACE("-- (%p)->(%s)\n", This, szPath);
1142 /**************************************************************************
1143 * IShellFolder_fnSetNameOf
1144 * Changes the name of a file object or subfolder, possibly changing its item
1145 * identifier in the process.
1148 * HWND hwndOwner, //[in ] Owner window for output
1149 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
1150 * LPCOLESTR lpszName, //[in ] the items new display name
1151 * DWORD dwFlags, //[in ] SHGNO formatting flags
1152 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
1154 static HRESULT WINAPI IShellFolder_fnSetNameOf(
1155 IShellFolder2 * iface,
1157 LPCITEMIDLIST pidl, /*simple pidl*/
1160 LPITEMIDLIST *pPidlOut)
1162 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1163 char szSrc[MAX_PATH], szDest[MAX_PATH];
1165 BOOL bIsFolder = _ILIsFolder(ILFindLastID(pidl));
1167 TRACE("(%p)->(%u,pidl=%p,%s,%lu,%p)\n",
1168 This,hwndOwner,pidl,debugstr_w(lpName),dwFlags,pPidlOut);
1170 /* build source path */
1171 if (dwFlags & SHGDN_INFOLDER)
1173 strcpy(szSrc, This->sMyPath);
1174 PathAddBackslashA(szSrc);
1175 len = strlen (szSrc);
1176 _ILSimpleGetText(pidl, szSrc+len, MAX_PATH-len);
1180 SHGetPathFromIDListA(pidl, szSrc);
1183 /* build destination path */
1184 strcpy(szDest, This->sMyPath);
1185 PathAddBackslashA(szDest);
1186 len = strlen (szDest);
1187 lstrcpynWtoA(szDest+len, lpName, MAX_PATH-len);
1189 TRACE("src=%s dest=%s\n", szSrc, szDest);
1190 if ( MoveFileA(szSrc, szDest) )
1192 if (pPidlOut) *pPidlOut = SHSimpleIDListFromPathA(szDest);
1193 SHChangeNotifyA( bIsFolder?SHCNE_RENAMEFOLDER:SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest);
1199 static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID(
1200 IShellFolder2 * iface,
1203 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1204 FIXME("(%p)\n",This);
1207 static HRESULT WINAPI IShellFolder_fnEnumSearches(
1208 IShellFolder2 * iface,
1209 IEnumExtraSearch **ppenum)
1211 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1212 FIXME("(%p)\n",This);
1215 static HRESULT WINAPI IShellFolder_fnGetDefaultColumn(
1216 IShellFolder2 * iface,
1221 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1223 TRACE("(%p)\n",This);
1225 if (pSort) *pSort = 0;
1226 if (pDisplay) *pDisplay = 0;
1230 static HRESULT WINAPI IShellFolder_fnGetDefaultColumnState(
1231 IShellFolder2 * iface,
1235 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1237 TRACE("(%p)\n",This);
1239 if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1241 *pcsFlags = GenericSFHeader[iColumn].pcsFlags;
1245 static HRESULT WINAPI IShellFolder_fnGetDetailsEx(
1246 IShellFolder2 * iface,
1248 const SHCOLUMNID *pscid,
1251 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1252 FIXME("(%p)\n",This);
1256 static HRESULT WINAPI IShellFolder_fnGetDetailsOf(
1257 IShellFolder2 * iface,
1262 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1263 HRESULT hr = E_FAIL;
1265 TRACE("(%p)->(%p %i %p)\n",This, pidl, iColumn, psd);
1267 if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1271 /* the header titles */
1272 psd->fmt = GenericSFHeader[iColumn].fmt;
1273 psd->cxChar = GenericSFHeader[iColumn].cxChar;
1274 psd->str.uType = STRRET_CSTRA;
1275 LoadStringA(shell32_hInstance, GenericSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
1280 /* the data from the pidl */
1284 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
1287 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
1290 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
1293 _ILGetFileDate(pidl, psd->str.u.cStr, MAX_PATH);
1295 case 4: /* attributes */
1296 _ILGetFileAttributes(pidl, psd->str.u.cStr, MAX_PATH);
1300 psd->str.uType = STRRET_CSTRA;
1305 static HRESULT WINAPI IShellFolder_fnMapNameToSCID(
1306 IShellFolder2 * iface,
1310 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1311 FIXME("(%p)\n",This);
1315 static ICOM_VTABLE(IShellFolder2) sfvt =
1317 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1318 IShellFolder_fnQueryInterface,
1319 IShellFolder_fnAddRef,
1320 IShellFolder_fnRelease,
1321 IShellFolder_fnParseDisplayName,
1322 IShellFolder_fnEnumObjects,
1323 IShellFolder_fnBindToObject,
1324 IShellFolder_fnBindToStorage,
1325 IShellFolder_fnCompareIDs,
1326 IShellFolder_fnCreateViewObject,
1327 IShellFolder_fnGetAttributesOf,
1328 IShellFolder_fnGetUIObjectOf,
1329 IShellFolder_fnGetDisplayNameOf,
1330 IShellFolder_fnSetNameOf,
1333 IShellFolder_fnGetDefaultSearchGUID,
1334 IShellFolder_fnEnumSearches,
1335 IShellFolder_fnGetDefaultColumn,
1336 IShellFolder_fnGetDefaultColumnState,
1337 IShellFolder_fnGetDetailsEx,
1338 IShellFolder_fnGetDetailsOf,
1339 IShellFolder_fnMapNameToSCID
1342 /****************************************************************************
1343 * ISFHelper for IShellFolder implementation
1346 static HRESULT WINAPI ISFHelper_fnQueryInterface(
1351 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1353 TRACE("(%p)\n", This);
1355 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObj);
1358 static ULONG WINAPI ISFHelper_fnAddRef(
1361 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1363 TRACE("(%p)\n", This);
1365 return IUnknown_AddRef(This->pUnkOuter);
1368 static ULONG WINAPI ISFHelper_fnRelease(
1371 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1373 TRACE("(%p)\n", This);
1375 return IUnknown_Release(This->pUnkOuter);
1379 /****************************************************************************
1380 * ISFHelper_fnAddFolder
1382 * creates a unique folder name
1385 static HRESULT WINAPI ISFHelper_fnGetUniqueName(
1390 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
1391 IEnumIDList * penum;
1393 char szText[MAX_PATH];
1394 char * szNewFolder = "New Folder";
1396 TRACE("(%p)(%s %u)\n", This, lpName, uLen);
1398 if (uLen < strlen(szNewFolder) + 4) return E_POINTER;
1400 strcpy(lpName, szNewFolder);
1402 hr = IShellFolder_fnEnumObjects(_IShellFolder2_(This), 0, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum);
1409 next: IEnumIDList_Reset(penum);
1410 while(S_OK == IEnumIDList_Next(penum, 1, &pidl, &dwFetched) && dwFetched)
1412 _ILSimpleGetText(pidl, szText, MAX_PATH);
1413 if (0 == strcasecmp(szText, lpName))
1415 sprintf(lpName, "%s %d", szNewFolder, i++);
1425 IEnumIDList_Release(penum);
1430 /****************************************************************************
1431 * ISFHelper_fnAddFolder
1433 * adds a new folder.
1436 static HRESULT WINAPI ISFHelper_fnAddFolder(
1440 LPITEMIDLIST* ppidlOut)
1442 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
1443 char lpstrNewDir[MAX_PATH];
1445 HRESULT hres = E_FAIL;
1447 TRACE("(%p)(%s %p)\n", This, lpName, ppidlOut);
1449 strcpy(lpstrNewDir, This->sMyPath);
1450 PathAddBackslashA(lpstrNewDir);
1451 strcat(lpstrNewDir, lpName);
1453 bRes = CreateDirectoryA(lpstrNewDir, NULL);
1457 LPITEMIDLIST pidl, pidlitem;
1459 pidlitem = SHSimpleIDListFromPathA(lpstrNewDir);
1461 pidl = ILCombine(This->absPidl, pidlitem);
1462 SHChangeNotifyA(SHCNE_MKDIR, SHCNF_IDLIST, pidl, NULL);
1465 if (ppidlOut) *ppidlOut = pidlitem;
1470 char lpstrText[128+MAX_PATH];
1471 char lpstrTempText[128];
1472 char lpstrCaption[256];
1474 /* Cannot Create folder because of permissions */
1475 LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText, sizeof(lpstrTempText));
1476 LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption, sizeof(lpstrCaption));
1477 sprintf(lpstrText,lpstrTempText, lpstrNewDir);
1478 MessageBoxA(hwnd,lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION);
1484 /****************************************************************************
1485 * ISFHelper_fnDeleteItems
1487 * deletes items in folder
1489 static HRESULT WINAPI ISFHelper_fnDeleteItems(
1492 LPCITEMIDLIST* apidl)
1494 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
1496 char szPath[MAX_PATH];
1498 TRACE("(%p)(%u %p)\n", This, cidl, apidl);
1500 for(i=0; i< cidl; i++)
1502 strcpy(szPath, This->sMyPath);
1503 PathAddBackslashA(szPath);
1504 _ILSimpleGetText(apidl[i], szPath+strlen(szPath), MAX_PATH);
1506 if (_ILIsFolder(apidl[i]))
1510 MESSAGE("delete %s\n", szPath);
1511 if (! SHELL_DeleteDirectoryA(szPath, TRUE)) return E_FAIL;
1512 pidl = ILCombine(This->absPidl, apidl[i]);
1513 SHChangeNotifyA(SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL);
1516 else if (_ILIsValue(apidl[i]))
1520 MESSAGE("delete %s\n", szPath);
1521 if (! DeleteFileA(szPath)) return E_FAIL;
1522 pidl = ILCombine(This->absPidl, apidl[i]);
1523 SHChangeNotifyA(SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL);
1531 /****************************************************************************
1532 * ISFHelper_fnCopyItems
1534 * copys items to this folder
1536 static HRESULT WINAPI ISFHelper_fnCopyItems(
1538 IShellFolder* pSFFrom,
1540 LPCITEMIDLIST *apidl)
1543 IPersistFolder2 * ppf2=NULL;
1544 char szSrcPath[MAX_PATH], szDstPath[MAX_PATH];
1545 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1547 TRACE("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
1549 IShellFolder_QueryInterface(pSFFrom, &IID_IPersistFolder2, (LPVOID*)&ppf2);
1553 if (SUCCEEDED(IPersistFolder2_GetCurFolder(ppf2, &pidl)))
1555 for (i=0; i<cidl; i++)
1557 SHGetPathFromIDListA(pidl, szSrcPath);
1558 PathAddBackslashA(szSrcPath);
1559 _ILSimpleGetText(apidl[i], szSrcPath+strlen(szSrcPath), MAX_PATH);
1561 strcpy(szDstPath, This->sMyPath);
1562 PathAddBackslashA(szDstPath);
1563 _ILSimpleGetText(apidl[i], szDstPath+strlen(szDstPath), MAX_PATH);
1564 MESSAGE("would copy %s to %s\n", szSrcPath, szDstPath);
1568 IPersistFolder2_Release(ppf2);
1573 static ICOM_VTABLE(ISFHelper) shvt =
1575 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1576 ISFHelper_fnQueryInterface,
1578 ISFHelper_fnRelease,
1579 ISFHelper_fnGetUniqueName,
1580 ISFHelper_fnAddFolder,
1581 ISFHelper_fnDeleteItems,
1582 ISFHelper_fnCopyItems,
1585 /***********************************************************************
1586 * [Desktopfolder] IShellFolder implementation
1588 static struct ICOM_VTABLE(IShellFolder2) sfdvt;
1590 static shvheader DesktopSFHeader [] =
1592 { IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
1593 { IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
1594 { IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
1595 { IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12 },
1596 { IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5 }
1598 #define DESKTOPSHELLVIEWCOLUMNS 5
1600 /**************************************************************************
1601 * ISF_Desktop_Constructor
1604 IShellFolder * ISF_Desktop_Constructor()
1606 IGenericSFImpl * sf;
1608 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
1610 ICOM_VTBL(sf)=&unkvt;
1611 sf->lpvtblShellFolder=&sfdvt;
1612 sf->absPidl=_ILCreateDesktop(); /* my qualified pidl */
1613 sf->pUnkOuter = (IUnknown *) &sf->lpVtbl;
1618 return _IShellFolder_(sf);
1621 /**************************************************************************
1622 * ISF_Desktop_fnQueryInterface
1624 * NOTES supports not IPersist/IPersistFolder
1626 static HRESULT WINAPI ISF_Desktop_fnQueryInterface(
1627 IShellFolder2 * iface,
1631 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1633 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1637 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
1639 *ppvObj = _IUnknown_(This);
1641 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
1643 *ppvObj = _IShellFolder_(This);
1645 else if(IsEqualIID(riid, &IID_IShellFolder2)) /*IShellFolder2*/
1647 *ppvObj = _IShellFolder_(This);
1652 IUnknown_AddRef((IUnknown*)(*ppvObj));
1653 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1656 TRACE("-- Interface: E_NOINTERFACE\n");
1657 return E_NOINTERFACE;
1660 /**************************************************************************
1661 * ISF_Desktop_fnParseDisplayName
1664 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
1667 static HRESULT WINAPI ISF_Desktop_fnParseDisplayName(
1668 IShellFolder2 * iface,
1671 LPOLESTR lpszDisplayName,
1673 LPITEMIDLIST *ppidl,
1674 DWORD *pdwAttributes)
1676 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1678 LPCWSTR szNext=NULL;
1679 LPITEMIDLIST pidlTemp=NULL;
1680 HRESULT hr=E_OUTOFMEMORY;
1682 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
1683 This,hwndOwner,pbcReserved,lpszDisplayName,
1684 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
1687 if (pchEaten) *pchEaten = 0; /* strange but like the original */
1689 /* fixme no real parsing implemented */
1690 pidlTemp = _ILCreateMyComputer();
1691 szNext = lpszDisplayName;
1693 if (szNext && *szNext)
1695 hr = SHELL32_ParseNextElement(hwndOwner, iface, &pidlTemp, (LPOLESTR)szNext, pchEaten, pdwAttributes);
1701 if (pdwAttributes && *pdwAttributes)
1703 SHELL32_GetItemAttributes(_IShellFolder_(This), pidlTemp, pdwAttributes);
1709 TRACE("(%p)->(-- ret=0x%08lx)\n", This, hr);
1714 /**************************************************************************
1715 * ISF_Desktop_fnEnumObjects
1717 static HRESULT WINAPI ISF_Desktop_fnEnumObjects(
1718 IShellFolder2 * iface,
1721 LPENUMIDLIST* ppEnumIDList)
1723 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1725 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
1727 *ppEnumIDList = NULL;
1728 *ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_DESK);
1730 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
1732 if(!*ppEnumIDList) return E_OUTOFMEMORY;
1737 /**************************************************************************
1738 * ISF_Desktop_fnBindToObject
1740 static HRESULT WINAPI ISF_Desktop_fnBindToObject( IShellFolder2 * iface, LPCITEMIDLIST pidl,
1741 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
1743 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1745 IShellFolder *pShellFolder, *pSubFolder;
1747 TRACE("(%p)->(pidl=%p,%p,\n\tIID:\t%s,%p)\n",
1748 This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
1752 if ((clsid=_ILGetGUIDPointer(pidl)))
1754 if ( IsEqualIID(clsid, &CLSID_MyComputer))
1756 pShellFolder = ISF_MyComputer_Constructor();
1760 /* shell extension */
1761 if (!SUCCEEDED(SHELL32_CoCreateInitSF (This->absPidl, pidl, clsid, riid, (LPVOID*)&pShellFolder)))
1763 return E_INVALIDARG;
1769 /* file system folder on the desktop */
1770 LPITEMIDLIST deskpidl, firstpidl, completepidl;
1771 IPersistFolder * ppf;
1774 SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, &deskpidl);
1775 firstpidl = ILCloneFirst(pidl);
1776 completepidl = ILCombine(deskpidl, firstpidl);
1778 pShellFolder = IShellFolder_Constructor(NULL, NULL);
1779 if (SUCCEEDED(IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder, (LPVOID*)&ppf)))
1781 IPersistFolder_Initialize(ppf, completepidl);
1782 IPersistFolder_Release(ppf);
1784 ILFree(completepidl);
1789 if (_ILIsPidlSimple(pidl)) /* no sub folders */
1791 *ppvOut = pShellFolder;
1793 else /* go deeper */
1795 IShellFolder_BindToObject(pShellFolder, ILGetNext(pidl), NULL, riid, (LPVOID)&pSubFolder);
1796 IShellFolder_Release(pShellFolder);
1797 *ppvOut = pSubFolder;
1800 TRACE("-- (%p) returning (%p)\n",This, *ppvOut);
1805 /**************************************************************************
1806 * ISF_Desktop_fnCreateViewObject
1808 static HRESULT WINAPI ISF_Desktop_fnCreateViewObject( IShellFolder2 * iface,
1809 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
1811 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1813 LPSHELLVIEW pShellView;
1814 HRESULT hr = E_INVALIDARG;
1816 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,debugstr_guid(riid),ppvOut);
1822 if(IsEqualIID(riid, &IID_IDropTarget))
1824 WARN("IDropTarget not implemented\n");
1827 else if(IsEqualIID(riid, &IID_IContextMenu))
1829 WARN("IContextMenu not implemented\n");
1832 else if(IsEqualIID(riid, &IID_IShellView))
1834 pShellView = IShellView_Constructor((IShellFolder*)iface);
1837 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
1838 IShellView_Release(pShellView);
1842 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
1846 /**************************************************************************
1847 * ISF_Desktop_fnGetAttributesOf
1849 static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf(
1850 IShellFolder2 * iface,
1852 LPCITEMIDLIST *apidl,
1855 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1859 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n",This,cidl,apidl, *rgfInOut);
1861 if ( (!cidl) || (!apidl) || (!rgfInOut))
1862 return E_INVALIDARG;
1864 while (cidl > 0 && *apidl)
1867 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
1872 TRACE("-- result=0x%08lx\n",*rgfInOut);
1877 /**************************************************************************
1878 * ISF_Desktop_fnGetDisplayNameOf
1881 * special case: pidl = null gives desktop-name back
1883 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf(
1884 IShellFolder2 * iface,
1889 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1891 CHAR szPath[MAX_PATH]= "";
1893 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,strRet);
1896 if(!strRet) return E_INVALIDARG;
1900 HCR_GetClassName(&CLSID_ShellDesktop, szPath, MAX_PATH);
1902 else if ( _ILIsPidlSimple(pidl) )
1904 _ILSimpleGetText(pidl, szPath, MAX_PATH);
1908 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, szPath, MAX_PATH)))
1909 return E_OUTOFMEMORY;
1911 strRet->uType = STRRET_CSTRA;
1912 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
1915 TRACE("-- (%p)->(%s)\n", This, szPath);
1919 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(
1920 IShellFolder2 * iface,
1923 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1924 FIXME("(%p)\n",This);
1927 static HRESULT WINAPI ISF_Desktop_fnEnumSearches(
1928 IShellFolder2 * iface,
1929 IEnumExtraSearch **ppenum)
1931 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1932 FIXME("(%p)\n",This);
1935 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn(
1936 IShellFolder2 * iface,
1941 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1943 TRACE("(%p)\n",This);
1945 if (pSort) *pSort = 0;
1946 if (pDisplay) *pDisplay = 0;
1950 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState(
1951 IShellFolder2 * iface,
1955 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1957 TRACE("(%p)\n",This);
1959 if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1961 *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
1965 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx(
1966 IShellFolder2 * iface,
1968 const SHCOLUMNID *pscid,
1971 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1972 FIXME("(%p)\n",This);
1976 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf(
1977 IShellFolder2 * iface,
1982 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1983 HRESULT hr = E_FAIL;;
1985 TRACE("(%p)->(%p %i %p)\n",This, pidl, iColumn, psd);
1987 if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1991 psd->fmt = DesktopSFHeader[iColumn].fmt;
1992 psd->cxChar = DesktopSFHeader[iColumn].cxChar;
1993 psd->str.uType = STRRET_CSTRA;
1994 LoadStringA(shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
1999 /* the data from the pidl */
2003 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
2006 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
2009 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
2012 _ILGetFileDate(pidl, psd->str.u.cStr, MAX_PATH);
2014 case 4: /* attributes */
2015 _ILGetFileAttributes(pidl, psd->str.u.cStr, MAX_PATH);
2019 psd->str.uType = STRRET_CSTRA;
2024 static HRESULT WINAPI ISF_Desktop_fnMapNameToSCID(
2025 IShellFolder2 * iface,
2029 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2030 FIXME("(%p)\n",This);
2034 static ICOM_VTABLE(IShellFolder2) sfdvt =
2036 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2037 ISF_Desktop_fnQueryInterface,
2038 IShellFolder_fnAddRef,
2039 IShellFolder_fnRelease,
2040 ISF_Desktop_fnParseDisplayName,
2041 ISF_Desktop_fnEnumObjects,
2042 ISF_Desktop_fnBindToObject,
2043 IShellFolder_fnBindToStorage,
2044 IShellFolder_fnCompareIDs,
2045 ISF_Desktop_fnCreateViewObject,
2046 ISF_Desktop_fnGetAttributesOf,
2047 IShellFolder_fnGetUIObjectOf,
2048 ISF_Desktop_fnGetDisplayNameOf,
2049 IShellFolder_fnSetNameOf,
2052 ISF_Desktop_fnGetDefaultSearchGUID,
2053 ISF_Desktop_fnEnumSearches,
2054 ISF_Desktop_fnGetDefaultColumn,
2055 ISF_Desktop_fnGetDefaultColumnState,
2056 ISF_Desktop_fnGetDetailsEx,
2057 ISF_Desktop_fnGetDetailsOf,
2058 ISF_Desktop_fnMapNameToSCID
2062 /***********************************************************************
2063 * IShellFolder [MyComputer] implementation
2066 static struct ICOM_VTABLE(IShellFolder2) sfmcvt;
2068 static shvheader MyComputerSFHeader [] =
2070 { IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
2071 { IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
2072 { IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
2073 { IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
2075 #define MYCOMPUTERSHELLVIEWCOLUMNS 4
2077 /**************************************************************************
2078 * ISF_MyComputer_Constructor
2080 static IShellFolder * ISF_MyComputer_Constructor(void)
2082 IGenericSFImpl * sf;
2084 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
2087 ICOM_VTBL(sf)=&unkvt;
2088 sf->lpvtblShellFolder=&sfmcvt;
2089 sf->lpvtblPersistFolder2 = &psfvt;
2090 sf->pclsid = (CLSID*)&CLSID_SFMyComp;
2091 sf->absPidl=_ILCreateMyComputer(); /* my qualified pidl */
2092 sf->pUnkOuter = (IUnknown *) &sf->lpVtbl;
2097 return _IShellFolder_(sf);
2100 /**************************************************************************
2101 * ISF_MyComputer_fnParseDisplayName
2103 static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName(
2104 IShellFolder2 * iface,
2107 LPOLESTR lpszDisplayName,
2109 LPITEMIDLIST *ppidl,
2110 DWORD *pdwAttributes)
2112 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2114 HRESULT hr = E_OUTOFMEMORY;
2115 LPCWSTR szNext=NULL;
2116 WCHAR szElement[MAX_PATH];
2117 CHAR szTempA[MAX_PATH];
2118 LPITEMIDLIST pidlTemp;
2120 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
2121 This,hwndOwner,pbcReserved,lpszDisplayName,
2122 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
2125 if (pchEaten) *pchEaten = 0; /* strange but like the original */
2127 /* do we have an absolute path name ? */
2128 if (PathGetDriveNumberW(lpszDisplayName) >= 0 &&
2129 lpszDisplayName[2] == (WCHAR)'\\')
2131 szNext = GetNextElementW(lpszDisplayName, szElement, MAX_PATH);
2132 lstrcpynWtoA(szTempA, szElement, lstrlenW(szElement) + 1);
2133 pidlTemp = _ILCreateDrive(szTempA);
2135 if (szNext && *szNext)
2137 hr = SHELL32_ParseNextElement(hwndOwner, iface, &pidlTemp, (LPOLESTR)szNext, pchEaten, pdwAttributes);
2141 if (pdwAttributes && *pdwAttributes)
2143 SHELL32_GetItemAttributes(_IShellFolder_(This), pidlTemp, pdwAttributes);
2150 TRACE("(%p)->(-- ret=0x%08lx)\n", This, hr);
2155 /**************************************************************************
2156 * ISF_MyComputer_fnEnumObjects
2158 static HRESULT WINAPI ISF_MyComputer_fnEnumObjects(
2159 IShellFolder2 * iface,
2162 LPENUMIDLIST* ppEnumIDList)
2164 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2166 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
2168 *ppEnumIDList = NULL;
2169 *ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_MYCOMP);
2171 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
2173 if(!*ppEnumIDList) return E_OUTOFMEMORY;
2178 /**************************************************************************
2179 * ISF_MyComputer_fnBindToObject
2181 static HRESULT WINAPI ISF_MyComputer_fnBindToObject( IShellFolder2 * iface, LPCITEMIDLIST pidl,
2182 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
2184 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2186 IShellFolder *pShellFolder, *pSubFolder;
2187 LPITEMIDLIST pidltemp;
2189 TRACE("(%p)->(pidl=%p,%p,\n\tIID:\t%s,%p)\n",
2190 This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
2192 if(!pidl || !ppvOut) return E_INVALIDARG;
2196 if ((clsid=_ILGetGUIDPointer(pidl)) && !IsEqualIID(clsid, &CLSID_MyComputer))
2198 if (!SUCCEEDED(SHELL32_CoCreateInitSF (This->absPidl, pidl, clsid, riid, (LPVOID*)&pShellFolder)))
2205 if (!_ILIsDrive(pidl)) return E_INVALIDARG;
2207 pidltemp = ILCloneFirst(pidl);
2208 pShellFolder = IShellFolder_Constructor(iface, pidltemp);
2212 if (_ILIsPidlSimple(pidl)) /* no sub folders */
2214 *ppvOut = pShellFolder;
2216 else /* go deeper */
2218 IShellFolder_BindToObject(pShellFolder, ILGetNext(pidl), NULL, &IID_IShellFolder, (LPVOID)&pSubFolder);
2219 IShellFolder_Release(pShellFolder);
2220 *ppvOut = pSubFolder;
2223 TRACE("-- (%p) returning (%p)\n",This, *ppvOut);
2228 /**************************************************************************
2229 * ISF_MyComputer_fnCreateViewObject
2231 static HRESULT WINAPI ISF_MyComputer_fnCreateViewObject( IShellFolder2 * iface,
2232 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
2234 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2236 LPSHELLVIEW pShellView;
2237 HRESULT hr = E_INVALIDARG;
2239 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,debugstr_guid(riid),ppvOut);
2245 if(IsEqualIID(riid, &IID_IDropTarget))
2247 WARN("IDropTarget not implemented\n");
2250 else if(IsEqualIID(riid, &IID_IContextMenu))
2252 WARN("IContextMenu not implemented\n");
2255 else if(IsEqualIID(riid, &IID_IShellView))
2257 pShellView = IShellView_Constructor((IShellFolder*)iface);
2260 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
2261 IShellView_Release(pShellView);
2265 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
2269 /**************************************************************************
2270 * ISF_MyComputer_fnGetAttributesOf
2272 static HRESULT WINAPI ISF_MyComputer_fnGetAttributesOf(
2273 IShellFolder2 * iface,
2275 LPCITEMIDLIST *apidl,
2278 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2282 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n",This,cidl,apidl,*rgfInOut);
2284 if ( (!cidl) || (!apidl) || (!rgfInOut))
2285 return E_INVALIDARG;
2287 while (cidl > 0 && *apidl)
2290 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
2295 TRACE("-- result=0x%08lx\n",*rgfInOut);
2299 /**************************************************************************
2300 * ISF_MyComputer_fnGetDisplayNameOf
2303 * The desktopfolder creates only complete paths (SHGDN_FORPARSING).
2304 * SHGDN_INFOLDER makes no sense.
2306 static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf(
2307 IShellFolder2 * iface,
2312 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2314 char szPath[MAX_PATH], szDrive[18];
2318 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,strRet);
2321 if(!strRet) return E_INVALIDARG;
2323 szPath[0]=0x00; szDrive[0]=0x00;
2326 bSimplePidl = _ILIsPidlSimple(pidl);
2328 if (_ILIsSpecialFolder(pidl))
2330 /* take names of special folders only if its only this folder */
2333 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
2338 if (!_ILIsDrive(pidl))
2340 ERR("Wrong pidl type\n");
2341 return E_INVALIDARG;
2344 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
2346 /* long view "lw_name (C:)" */
2347 if ( bSimplePidl && !(dwFlags & SHGDN_FORPARSING))
2349 DWORD dwVolumeSerialNumber,dwMaximumComponetLength,dwFileSystemFlags;
2351 GetVolumeInformationA(szPath,szDrive,12,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
2352 strcat (szDrive," (");
2353 strncat (szDrive, szPath, 2);
2354 strcat (szDrive,")");
2355 strcpy (szPath, szDrive);
2359 if (!bSimplePidl) /* go deeper if needed */
2361 PathAddBackslashA(szPath);
2362 len = strlen(szPath);
2364 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_FORPARSING, szPath + len, MAX_PATH - len)))
2365 return E_OUTOFMEMORY;
2367 strRet->uType = STRRET_CSTRA;
2368 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
2371 TRACE("-- (%p)->(%s)\n", This, szPath);
2375 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID(
2376 IShellFolder2 * iface,
2379 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2380 FIXME("(%p)\n",This);
2383 static HRESULT WINAPI ISF_MyComputer_fnEnumSearches(
2384 IShellFolder2 * iface,
2385 IEnumExtraSearch **ppenum)
2387 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2388 FIXME("(%p)\n",This);
2391 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn(
2392 IShellFolder2 * iface,
2397 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2399 TRACE("(%p)\n",This);
2401 if (pSort) *pSort = 0;
2402 if (pDisplay) *pDisplay = 0;
2406 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState(
2407 IShellFolder2 * iface,
2411 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2413 TRACE("(%p)\n",This);
2415 if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS ) return E_INVALIDARG;
2417 *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
2421 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx(
2422 IShellFolder2 * iface,
2424 const SHCOLUMNID *pscid,
2427 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2428 FIXME("(%p)\n",This);
2433 /* fixme: drive size >4GB is rolling over */
2434 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf(
2435 IShellFolder2 * iface,
2440 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2443 TRACE("(%p)->(%p %i %p)\n",This, pidl, iColumn, psd);
2445 if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS ) return E_INVALIDARG;
2449 psd->fmt = MyComputerSFHeader[iColumn].fmt;
2450 psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
2451 psd->str.uType = STRRET_CSTRA;
2452 LoadStringA(shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
2457 char szPath[MAX_PATH];
2458 ULARGE_INTEGER ulBytes;
2460 psd->str.u.cStr[0] = 0x00;
2461 psd->str.uType = STRRET_CSTRA;
2465 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
2468 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
2470 case 2: /* total size */
2471 if (_ILIsDrive(pidl))
2473 _ILSimpleGetText(pidl, szPath, MAX_PATH);
2474 GetDiskFreeSpaceExA(szPath, NULL, &ulBytes, NULL);
2475 StrFormatByteSizeA(ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
2478 case 3: /* free size */
2479 if (_ILIsDrive(pidl))
2481 _ILSimpleGetText(pidl, szPath, MAX_PATH);
2482 GetDiskFreeSpaceExA(szPath, &ulBytes, NULL, NULL);
2483 StrFormatByteSizeA(ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
2492 static HRESULT WINAPI ISF_MyComputer_fnMapNameToSCID(
2493 IShellFolder2 * iface,
2497 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2498 FIXME("(%p)\n",This);
2502 static ICOM_VTABLE(IShellFolder2) sfmcvt =
2504 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2505 IShellFolder_fnQueryInterface,
2506 IShellFolder_fnAddRef,
2507 IShellFolder_fnRelease,
2508 ISF_MyComputer_fnParseDisplayName,
2509 ISF_MyComputer_fnEnumObjects,
2510 ISF_MyComputer_fnBindToObject,
2511 IShellFolder_fnBindToStorage,
2512 IShellFolder_fnCompareIDs,
2513 ISF_MyComputer_fnCreateViewObject,
2514 ISF_MyComputer_fnGetAttributesOf,
2515 IShellFolder_fnGetUIObjectOf,
2516 ISF_MyComputer_fnGetDisplayNameOf,
2517 IShellFolder_fnSetNameOf,
2520 ISF_MyComputer_fnGetDefaultSearchGUID,
2521 ISF_MyComputer_fnEnumSearches,
2522 ISF_MyComputer_fnGetDefaultColumn,
2523 ISF_MyComputer_fnGetDefaultColumnState,
2524 ISF_MyComputer_fnGetDetailsEx,
2525 ISF_MyComputer_fnGetDetailsOf,
2526 ISF_MyComputer_fnMapNameToSCID
2530 /************************************************************************
2531 * ISFPersistFolder_QueryInterface (IUnknown)
2534 static HRESULT WINAPI ISFPersistFolder2_QueryInterface(
2535 IPersistFolder2 * iface,
2539 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2541 TRACE("(%p)\n", This);
2543 return IUnknown_QueryInterface(This->pUnkOuter, iid, ppvObj);
2546 /************************************************************************
2547 * ISFPersistFolder_AddRef (IUnknown)
2550 static ULONG WINAPI ISFPersistFolder2_AddRef(
2551 IPersistFolder2 * iface)
2553 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2555 TRACE("(%p)\n", This);
2557 return IUnknown_AddRef(This->pUnkOuter);
2560 /************************************************************************
2561 * ISFPersistFolder_Release (IUnknown)
2564 static ULONG WINAPI ISFPersistFolder2_Release(
2565 IPersistFolder2 * iface)
2567 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2569 TRACE("(%p)\n", This);
2571 return IUnknown_Release(This->pUnkOuter);
2574 /************************************************************************
2575 * ISFPersistFolder_GetClassID (IPersist)
2577 static HRESULT WINAPI ISFPersistFolder2_GetClassID(
2578 IPersistFolder2 * iface,
2581 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2583 TRACE("(%p)\n", This);
2585 if (!lpClassId) return E_POINTER;
2586 *lpClassId = *This->pclsid;
2591 /************************************************************************
2592 * ISFPersistFolder_Initialize (IPersistFolder)
2595 * sMyPath is not set. Don't know how to handle in a non rooted environment.
2597 static HRESULT WINAPI ISFPersistFolder2_Initialize(
2598 IPersistFolder2 * iface,
2601 char sTemp[MAX_PATH];
2602 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2604 TRACE("(%p)->(%p)\n", This, pidl);
2606 /* free the old stuff */
2609 SHFree(This->absPidl);
2610 This->absPidl = NULL;
2614 SHFree(This->sMyPath);
2615 This->sMyPath = NULL;
2619 This->absPidl = ILClone(pidl);
2622 if (SHGetPathFromIDListA(pidl, sTemp))
2624 This->sMyPath = SHAlloc(strlen(sTemp)+1);
2625 strcpy(This->sMyPath, sTemp);
2628 TRACE("--(%p)->(%s)\n", This, This->sMyPath);
2633 /**************************************************************************
2634 * IPersistFolder2_fnGetCurFolder
2636 static HRESULT WINAPI ISFPersistFolder2_fnGetCurFolder(
2637 IPersistFolder2 * iface,
2638 LPITEMIDLIST * pidl)
2640 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2642 TRACE("(%p)->(%p)\n",This, pidl);
2644 if (!pidl) return E_POINTER;
2646 *pidl = ILClone(This->absPidl);
2651 static ICOM_VTABLE(IPersistFolder2) psfvt =
2653 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2654 ISFPersistFolder2_QueryInterface,
2655 ISFPersistFolder2_AddRef,
2656 ISFPersistFolder2_Release,
2657 ISFPersistFolder2_GetClassID,
2658 ISFPersistFolder2_Initialize,
2659 ISFPersistFolder2_fnGetCurFolder
2662 /****************************************************************************
2663 * ISFDropTarget implementation
2665 static BOOL ISFDropTarget_QueryDrop(
2670 DWORD dwEffect = *pdwEffect;
2672 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2674 *pdwEffect = DROPEFFECT_NONE;
2676 if (This->fAcceptFmt)
2677 { /* Does our interpretation of the keystate ... */
2678 *pdwEffect = KeyStateToDropEffect(dwKeyState);
2680 /* ... matches the desired effect ? */
2681 if (dwEffect & *pdwEffect)
2689 static HRESULT WINAPI ISFDropTarget_QueryInterface(
2694 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2696 TRACE("(%p)\n", This);
2698 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObj);
2701 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
2703 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2705 TRACE("(%p)\n", This);
2707 return IUnknown_AddRef(This->pUnkOuter);
2710 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
2712 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2714 TRACE("(%p)\n", This);
2716 return IUnknown_Release(This->pUnkOuter);
2719 static HRESULT WINAPI ISFDropTarget_DragEnter(
2721 IDataObject *pDataObject,
2728 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2730 TRACE("(%p)->(DataObject=%p)\n",This,pDataObject);
2732 InitFormatEtc(fmt, This->cfShellIDList, TYMED_HGLOBAL);
2734 This->fAcceptFmt = (S_OK == IDataObject_QueryGetData(pDataObject, &fmt)) ? TRUE : FALSE;
2736 ISFDropTarget_QueryDrop(iface, dwKeyState, pdwEffect);
2741 static HRESULT WINAPI ISFDropTarget_DragOver(
2747 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2749 TRACE("(%p)\n",This);
2751 if(!pdwEffect) return E_INVALIDARG;
2753 ISFDropTarget_QueryDrop(iface, dwKeyState, pdwEffect);
2758 static HRESULT WINAPI ISFDropTarget_DragLeave(
2761 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2763 TRACE("(%p)\n",This);
2765 This->fAcceptFmt = FALSE;
2770 static HRESULT WINAPI ISFDropTarget_Drop(
2772 IDataObject* pDataObject,
2777 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2779 FIXME("(%p) object dropped\n",This);
2784 static struct ICOM_VTABLE(IDropTarget) dtvt =
2786 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2787 ISFDropTarget_QueryInterface,
2788 ISFDropTarget_AddRef,
2789 ISFDropTarget_Release,
2790 ISFDropTarget_DragEnter,
2791 ISFDropTarget_DragOver,
2792 ISFDropTarget_DragLeave,