4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998, 1999 Juergen Schmied
7 * IShellFolder2 and related interfaces
23 #include "wine/obj_base.h"
24 #include "wine/obj_dragdrop.h"
25 #include "wine/obj_shellfolder.h"
26 #include "undocshell.h"
27 #include "shell32_main.h"
30 #include "shellfolder.h"
31 #include "debugtools.h"
33 DEFAULT_DEBUG_CHANNEL(shell);
36 /***************************************************************************
37 * debughelper: print out the return adress
38 * helps especially to track down unbalanced AddRef/Release
43 #define _CALL_TRACE TRACE("called from: 0x%08x\n", *( ((UINT*)&iface)-1 ));
57 /***************************************************************************
58 * GetNextElement (internal function)
60 * gets a part of a string till the first backslash
63 * pszNext [IN] string to get the element from
64 * pszOut [IN] pointer to buffer whitch receives string
65 * dwOut [IN] length of pszOut
68 * LPSTR pointer to first, not yet parsed char
71 static LPCWSTR GetNextElementW(LPCWSTR pszNext,LPWSTR pszOut,DWORD dwOut)
72 { LPCWSTR pszTail = pszNext;
74 TRACE("(%s %p 0x%08lx)\n",debugstr_w(pszNext),pszOut,dwOut);
78 if(!pszNext || !*pszNext)
81 while(*pszTail && (*pszTail != (WCHAR)'\\'))
84 dwCopy = (WCHAR*)pszTail - (WCHAR*)pszNext + 1;
85 lstrcpynW(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
92 TRACE("--(%s %s 0x%08lx %p)\n",debugstr_w(pszNext),debugstr_w(pszOut),dwOut,pszTail);
96 static HRESULT SHELL32_ParseNextElement(
99 LPITEMIDLIST * pidlInOut,
102 DWORD *pdwAttributes)
104 HRESULT hr = E_OUTOFMEMORY;
105 LPITEMIDLIST pidlOut, pidlTemp = NULL;
106 IShellFolder *psfChild;
108 TRACE("(%p, %p, %s)\n",psf, pidlInOut ? *pidlInOut : NULL, debugstr_w(szNext));
111 /* get the shellfolder for the child pidl and let it analyse further */
112 hr = IShellFolder_BindToObject(psf, *pidlInOut, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
116 hr = IShellFolder_ParseDisplayName(psfChild, hwndOwner, NULL, szNext, pEaten, &pidlOut, pdwAttributes);
117 IShellFolder_Release(psfChild);
119 pidlTemp = ILCombine(*pidlInOut, pidlOut);
126 *pidlInOut = pidlTemp;
128 TRACE("-- pidl=%p ret=0x%08lx\n", pidlInOut? *pidlInOut: NULL, hr);
132 /***********************************************************************
133 * SHELL32_CoCreateInitSF
135 * creates a initialized shell folder
137 static HRESULT SHELL32_CoCreateInitSF (
138 LPITEMIDLIST pidlRoot,
139 LPITEMIDLIST pidlChild,
145 LPITEMIDLIST absPidl;
146 IShellFolder2 *pShellFolder;
147 IPersistFolder *pPersistFolder;
149 TRACE("%p %p\n", pidlRoot, pidlChild);
153 /* we have to ask first for IPersistFolder, some special folders are expecting this */
154 hr = SHCoCreateInstance(NULL, clsid, NULL, &IID_IPersistFolder, (LPVOID*)&pPersistFolder);
157 hr = IPersistFolder_QueryInterface(pPersistFolder, iid, (LPVOID*)&pShellFolder);
160 absPidl = ILCombine (pidlRoot, pidlChild);
161 hr = IPersistFolder_Initialize(pPersistFolder, absPidl);
162 IPersistFolder_Release(pPersistFolder);
164 *ppvOut = pShellFolder;
168 TRACE("-- ret=0x%08lx\n", hr);
172 static HRESULT SHELL32_GetDisplayNameOfChild(
179 LPITEMIDLIST pidlFirst, pidlNext;
180 IShellFolder2 * psfChild;
181 HRESULT hr = E_OUTOFMEMORY;
184 TRACE("(%p)->(pidl=%p 0x%08lx %p 0x%08lx)\n",psf,pidl,dwFlags,szOut, dwOutLen);
187 if ((pidlFirst = ILCloneFirst(pidl)))
189 hr = IShellFolder_BindToObject(psf, pidlFirst, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
192 pidlNext = ILGetNext(pidl);
194 hr = IShellFolder_GetDisplayNameOf(psfChild, pidlNext, dwFlags | SHGDN_INFOLDER, &strTemp);
197 hr = StrRetToStrNA(szOut, dwOutLen, &strTemp, pidlNext);
200 IShellFolder_Release(psfChild);
205 TRACE("-- ret=0x%08lx %s\n", hr, szOut);
210 /***********************************************************************
211 * SHELL32_GetItemAttributes
215 * folder: 0xE0000177 FILESYSTEM | HASSUBFOLDER | FOLDER
216 * file: 0x40000177 FILESYSTEM
217 * drive: 0xf0000144 FILESYSTEM | HASSUBFOLDER | FOLDER | FILESYSANCESTOR
218 * mycomputer: 0xb0000154 HASSUBFOLDER | FOLDER | FILESYSANCESTOR
219 * (seems to be default for shell extensions if no registry entry exists)
221 * This functions does not set flags!! It only resets flags when nessesary.
223 static HRESULT SHELL32_GetItemAttributes(
226 LPDWORD pdwAttributes)
231 TRACE("0x%08lx\n", *pdwAttributes);
233 if (*pdwAttributes & (0xcff3fe88))
234 WARN("attribute 0x%08lx not implemented\n", *pdwAttributes);
235 *pdwAttributes &= ~SFGAO_LINK; /* FIXME: for native filedialogs */
237 if (_ILIsDrive(pidl))
239 *pdwAttributes &= 0xf0000144;
241 else if ((clsid=_ILGetGUIDPointer(pidl)))
243 if (HCR_GetFolderAttributes(clsid, &dwAttributes))
245 *pdwAttributes &= dwAttributes;
249 *pdwAttributes &= 0xb0000154;
252 else if (_ILGetDataPointer(pidl))
254 dwAttributes = _ILGetFileAttributes(pidl, NULL, 0);
255 *pdwAttributes &= ~SFGAO_FILESYSANCESTOR;
257 if(( SFGAO_FOLDER & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
258 *pdwAttributes &= ~(SFGAO_FOLDER|SFGAO_HASSUBFOLDER);
260 if(( SFGAO_HIDDEN & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_HIDDEN))
261 *pdwAttributes &= ~SFGAO_HIDDEN;
263 if(( SFGAO_READONLY & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_READONLY))
264 *pdwAttributes &= ~SFGAO_READONLY;
268 *pdwAttributes &= 0xb0000154;
270 TRACE("-- 0x%08lx\n", *pdwAttributes);
274 /***********************************************************************
275 * IShellFolder implementation
280 ICOM_VFIELD(IUnknown);
282 ICOM_VTABLE(IShellFolder2)* lpvtblShellFolder;
283 ICOM_VTABLE(IPersistFolder2)* lpvtblPersistFolder2;
284 ICOM_VTABLE(IDropTarget)* lpvtblDropTarget;
285 ICOM_VTABLE(ISFHelper)* lpvtblSFHelper;
287 IUnknown *pUnkOuter; /* used for aggregation */
292 LPITEMIDLIST absPidl; /* complete pidl */
294 UINT cfShellIDList; /* clipboardformat for IDropTarget */
295 BOOL fAcceptFmt; /* flag for pending Drop */
298 static struct ICOM_VTABLE(IUnknown) unkvt;
299 static struct ICOM_VTABLE(IShellFolder2) sfvt;
300 static struct ICOM_VTABLE(IPersistFolder2) psfvt;
301 static struct ICOM_VTABLE(IDropTarget) dtvt;
302 static struct ICOM_VTABLE(ISFHelper) shvt;
304 static IShellFolder * ISF_MyComputer_Constructor(void);
306 #define _IShellFolder2_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblShellFolder)))
307 #define _ICOM_THIS_From_IShellFolder2(class, name) class* This = (class*)(((char*)name)-_IShellFolder2_Offset);
309 #define _IPersistFolder_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder2)))
310 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder_Offset);
312 #define _IDropTarget_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblDropTarget)))
313 #define _ICOM_THIS_From_IDropTarget(class, name) class* This = (class*)(((char*)name)-_IDropTarget_Offset);
315 #define _ISFHelper_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblSFHelper)))
316 #define _ICOM_THIS_From_ISFHelper(class, name) class* This = (class*)(((char*)name)-_ISFHelper_Offset);
318 converts This to a interface pointer
320 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
321 #define _IShellFolder_(This) (IShellFolder*)&(This->lpvtblShellFolder)
322 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpvtblShellFolder)
323 #define _IPersist_(This) (IPersist*)&(This->lpvtblPersistFolder2)
324 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpvtblPersistFolder2)
325 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpvtblPersistFolder2)
326 #define _IDropTarget_(This) (IDropTarget*)&(This->lpvtblDropTarget)
327 #define _ISFHelper_(This) (ISFHelper*)&(This->lpvtblSFHelper)
328 /**************************************************************************
329 * registers clipboardformat once
331 static void SF_RegisterClipFmt (IGenericSFImpl * This)
333 TRACE("(%p)\n", This);
335 if (!This->cfShellIDList)
337 This->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
341 /**************************************************************************
342 * we need a separate IUnknown to handle aggregation
345 static HRESULT WINAPI IUnknown_fnQueryInterface(
350 ICOM_THIS(IGenericSFImpl, iface);
353 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
357 if(IsEqualIID(riid, &IID_IUnknown)) *ppvObj = _IUnknown_(This);
358 else if(IsEqualIID(riid, &IID_IShellFolder)) *ppvObj = _IShellFolder_(This);
359 else if(IsEqualIID(riid, &IID_IShellFolder2)) *ppvObj = _IShellFolder_(This);
360 else if(IsEqualIID(riid, &IID_IPersist)) *ppvObj = _IPersist_(This);
361 else if(IsEqualIID(riid, &IID_IPersistFolder)) *ppvObj = _IPersistFolder_(This);
362 else if(IsEqualIID(riid, &IID_IPersistFolder2)) *ppvObj = _IPersistFolder2_(This);
363 else if(IsEqualIID(riid, &IID_ISFHelper)) *ppvObj = _ISFHelper_(This);
364 else if(IsEqualIID(riid, &IID_IDropTarget))
366 *ppvObj = _IDropTarget_(This);
367 SF_RegisterClipFmt(This);
372 IUnknown_AddRef((IUnknown*)(*ppvObj));
373 TRACE("-- Interface = %p\n", *ppvObj);
376 TRACE("-- Interface: E_NOINTERFACE\n");
377 return E_NOINTERFACE;
380 static ULONG WINAPI IUnknown_fnAddRef(IUnknown * iface)
382 ICOM_THIS(IGenericSFImpl, iface);
385 TRACE("(%p)->(count=%lu)\n",This,This->ref);
388 return ++(This->ref);
391 static ULONG WINAPI IUnknown_fnRelease(IUnknown * iface)
393 ICOM_THIS(IGenericSFImpl, iface);
396 TRACE("(%p)->(count=%lu)\n",This,This->ref);
401 TRACE("-- destroying IShellFolder(%p)\n",This);
403 if (pdesktopfolder == _IShellFolder_(This))
406 TRACE("-- destroyed IShellFolder(%p) was Desktopfolder\n",This);
408 if(This->absPidl) SHFree(This->absPidl);
409 if(This->sMyPath) SHFree(This->sMyPath);
410 HeapFree(GetProcessHeap(),0,This);
416 static ICOM_VTABLE(IUnknown) unkvt =
418 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
419 IUnknown_fnQueryInterface,
424 static shvheader GenericSFHeader [] =
426 { IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
427 { IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
428 { IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
429 { IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12 },
430 { IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5 }
432 #define GENERICSHELLVIEWCOLUMNS 5
434 /**************************************************************************
435 * IShellFolder_Constructor
438 * creating undocumented ShellFS_Folder as part of an aggregation
439 * {F3364BA0-65B9-11CE-A9BA-00AA004AE837}
442 * when pUnkOuter = 0 then rrid = IID_IShellFolder is returned
444 HRESULT IFSFolder_Constructor(
445 IUnknown * pUnkOuter,
452 TRACE("unkOut=%p riid=%s\n",pUnkOuter, debugstr_guid(riid));
454 if(pUnkOuter && ! IsEqualIID(riid, &IID_IUnknown))
456 hr = CLASS_E_NOAGGREGATION; /* forbidden by definition */
460 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
464 ICOM_VTBL(sf)=&unkvt;
465 sf->lpvtblShellFolder=&sfvt;
466 sf->lpvtblPersistFolder2=&psfvt;
467 sf->lpvtblDropTarget=&dtvt;
468 sf->lpvtblSFHelper=&shvt;
470 sf->pclsid = (CLSID*)&CLSID_SFFile;
471 sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_(sf);
472 *ppv = _IUnknown_(sf);
483 /**************************************************************************
484 * IShellFolder_Constructor
487 * THIS points to the parent folder
490 IShellFolder * IShellFolder_Constructor(
491 IShellFolder2 * iface,
497 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
499 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
502 ICOM_VTBL(sf)=&unkvt;
503 sf->lpvtblShellFolder=&sfvt;
504 sf->lpvtblPersistFolder2=&psfvt;
505 sf->lpvtblDropTarget=&dtvt;
506 sf->lpvtblSFHelper=&shvt;
508 sf->pclsid = (CLSID*)&CLSID_SFFile;
509 sf->pUnkOuter = _IUnknown_(sf);
511 TRACE("(%p)->(parent=%p, pidl=%p)\n",sf,This, pidl);
514 if(pidl && iface) /* do we have a pidl? */
518 sf->absPidl = ILCombine(This->absPidl, pidl); /* build a absolute pidl */
520 if (!_ILIsSpecialFolder(pidl)) /* only file system paths */
522 if(This->sMyPath) /* get the size of the parents path */
524 dwSize += strlen(This->sMyPath) ;
525 TRACE("-- (%p)->(parent's path=%s)\n",sf, debugstr_a(This->sMyPath));
528 dwSize += _ILSimpleGetText(pidl,NULL,0); /* add the size of our name*/
529 sf->sMyPath = SHAlloc(dwSize + 2); /* '\0' and backslash */
531 if(!sf->sMyPath) return NULL;
534 if(This->sMyPath) /* if the parent has a path, get it*/
536 strcpy(sf->sMyPath, This->sMyPath);
537 PathAddBackslashA (sf->sMyPath);
540 len = strlen(sf->sMyPath);
541 _ILSimpleGetText(pidl, sf->sMyPath + len, dwSize+2 - len);
544 TRACE("-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->absPidl,debugstr_a(sf->sMyPath));
550 return _IShellFolder_(sf);
553 /**************************************************************************
554 * IShellFolder_fnQueryInterface
557 * REFIID riid [in ] Requested InterfaceID
558 * LPVOID* ppvObject [out] Interface* to hold the result
560 static HRESULT WINAPI IShellFolder_fnQueryInterface(
561 IShellFolder2 * iface,
565 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
568 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
570 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObj);
573 /**************************************************************************
574 * IShellFolder_AddRef
577 static ULONG WINAPI IShellFolder_fnAddRef(IShellFolder2 * iface)
579 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
582 TRACE("(%p)->(count=%lu)\n",This,This->ref);
584 return IUnknown_AddRef(This->pUnkOuter);
587 /**************************************************************************
588 * IShellFolder_fnRelease
590 static ULONG WINAPI IShellFolder_fnRelease(IShellFolder2 * iface)
592 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
595 TRACE("(%p)->(count=%lu)\n",This,This->ref);
597 return IUnknown_Release(This->pUnkOuter);
600 /**************************************************************************
601 * IShellFolder_fnParseDisplayName
603 * HWND hwndOwner, //[in ] Parent window for any message's
604 * LPBC pbc, //[in ] reserved
605 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
606 * ULONG* pchEaten, //[out] (unicode) characters processed
607 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
608 * ULONG* pdwAttributes //[out] items attributes
611 * every folder tries to parse only its own (the leftmost) pidl and creates a
612 * subfolder to evaluate the remaining parts
613 * now we can parse into namespaces implemented by shell extensions
615 * behaviour on win98: lpszDisplayName=NULL -> chrash
616 * lpszDisplayName="" -> returns mycoputer-pidl
619 * pdwAttributes: not set
620 * pchEaten: not set like in windows
622 static HRESULT WINAPI IShellFolder_fnParseDisplayName(
623 IShellFolder2 * iface,
626 LPOLESTR lpszDisplayName,
629 DWORD *pdwAttributes)
631 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
633 HRESULT hr = E_OUTOFMEMORY;
635 WCHAR szElement[MAX_PATH];
636 CHAR szTempA[MAX_PATH], szPath[MAX_PATH];
637 LPITEMIDLIST pidlTemp=NULL;
639 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
640 This,hwndOwner,pbcReserved,lpszDisplayName,
641 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
643 if (!lpszDisplayName || !ppidl) return E_INVALIDARG;
645 if (pchEaten) *pchEaten = 0; /* strange but like the original */
647 if (*lpszDisplayName)
649 /* get the next element */
650 szNext = GetNextElementW(lpszDisplayName, szElement, MAX_PATH);
652 /* build the full pathname to the element */
653 WideCharToMultiByte( CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL );
654 strcpy(szPath, This->sMyPath);
655 PathAddBackslashA(szPath);
656 strcat(szPath, szTempA);
659 pidlTemp = SHSimpleIDListFromPathA(szPath);
663 /* try to analyse the next element */
664 if (szNext && *szNext)
666 hr = SHELL32_ParseNextElement(hwndOwner, iface, &pidlTemp, (LPOLESTR)szNext, pchEaten, pdwAttributes);
670 if (pdwAttributes && *pdwAttributes)
672 SHELL32_GetItemAttributes(_IShellFolder_(This), pidlTemp, pdwAttributes);
673 /* WIN32_FIND_DATAA fd;
674 SHGetDataFromIDListA(_IShellFolder_(This), pidlTemp, SHGDFIL_FINDDATA, &fd, sizeof(fd));
675 if (!(FILE_ATTRIBUTE_DIRECTORY & fd.dwFileAttributes))
676 *pdwAttributes &= ~SFGAO_FOLDER;
677 if (FILE_ATTRIBUTE_READONLY & fd.dwFileAttributes)
678 *pdwAttributes &= ~(SFGAO_CANDELETE|SFGAO_CANMOVE|SFGAO_CANRENAME );
691 TRACE("(%p)->(-- pidl=%p ret=0x%08lx)\n", This, ppidl? *ppidl:0, hr);
696 /**************************************************************************
697 * IShellFolder_fnEnumObjects
699 * HWND hwndOwner, //[in ] Parent Window
700 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
701 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
703 static HRESULT WINAPI IShellFolder_fnEnumObjects(
704 IShellFolder2 * iface,
707 LPENUMIDLIST* ppEnumIDList)
709 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
711 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
713 *ppEnumIDList = NULL;
714 *ppEnumIDList = IEnumIDList_Constructor (This->sMyPath, dwFlags, EIDL_FILE);
716 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
718 if(!*ppEnumIDList) return E_OUTOFMEMORY;
723 /**************************************************************************
724 * IShellFolder_fnBindToObject
726 * LPCITEMIDLIST pidl, //[in ] relative pidl to open
727 * LPBC pbc, //[in ] reserved
728 * REFIID riid, //[in ] Initial Interface
729 * LPVOID* ppvObject //[out] Interface*
731 static HRESULT WINAPI IShellFolder_fnBindToObject( IShellFolder2 * iface, LPCITEMIDLIST pidl,
732 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
734 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
736 IShellFolder *pShellFolder, *pSubFolder;
737 IPersistFolder *pPersistFolder;
738 LPITEMIDLIST absPidl;
740 TRACE("(%p)->(pidl=%p,%p,\n\tIID:\t%s,%p)\n",This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
742 if(!pidl || !ppvOut) return E_INVALIDARG;
746 if ((iid=_ILGetGUIDPointer(pidl)))
748 /* we have to create a alien folder */
749 if ( SUCCEEDED(SHCoCreateInstance(NULL, iid, NULL, riid, (LPVOID*)&pShellFolder))
750 && SUCCEEDED(IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder, (LPVOID*)&pPersistFolder)))
752 absPidl = ILCombine (This->absPidl, pidl);
753 IPersistFolder_Initialize(pPersistFolder, absPidl);
754 IPersistFolder_Release(pPersistFolder);
762 else if(_ILIsFolder(pidl))
764 LPITEMIDLIST pidltemp = ILCloneFirst(pidl);
765 pShellFolder = IShellFolder_Constructor(iface, pidltemp);
770 ERR("can't bind to a file\n");
774 if (_ILIsPidlSimple(pidl))
776 *ppvOut = pShellFolder;
780 IShellFolder_BindToObject(pShellFolder, ILGetNext(pidl), NULL, &IID_IShellFolder, (LPVOID)&pSubFolder);
781 IShellFolder_Release(pShellFolder);
782 *ppvOut = pSubFolder;
785 TRACE("-- (%p) returning (%p)\n",This, *ppvOut);
790 /**************************************************************************
791 * IShellFolder_fnBindToStorage
793 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
794 * LPBC pbc, //[in ] reserved
795 * REFIID riid, //[in ] Initial storage interface
796 * LPVOID* ppvObject //[out] Interface* returned
798 static HRESULT WINAPI IShellFolder_fnBindToStorage(
799 IShellFolder2 * iface,
805 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
807 FIXME("(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",
808 This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
814 /**************************************************************************
815 * IShellFolder_fnCompareIDs
818 * LPARAM lParam, //[in ] Column?
819 * LPCITEMIDLIST pidl1, //[in ] simple pidl
820 * LPCITEMIDLIST pidl2) //[in ] simple pidl
823 * Special case - If one of the items is a Path and the other is a File,
824 * always make the Path come before the File.
827 * use SCODE_CODE() on the return value to get the result
830 static HRESULT WINAPI IShellFolder_fnCompareIDs(
831 IShellFolder2 * iface,
836 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
838 CHAR szTemp1[MAX_PATH];
839 CHAR szTemp2[MAX_PATH];
842 HRESULT hr = E_OUTOFMEMORY;
843 LPCITEMIDLIST pidlTemp;
846 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",This,lParam,pidl1,pidl2);
850 if (!pidl1 && !pidl2)
852 hr = ResultFromShort(0);
856 hr = ResultFromShort(-1);
860 hr = ResultFromShort(1);
865 pd1 = _ILGetDataPointer(pidl1);
866 pd2 = _ILGetDataPointer(pidl2);
868 /* compate the types. sort order is the PT_* constant */
869 pt1 = ( pd1 ? pd1->type: PT_DESKTOP);
870 pt2 = ( pd2 ? pd2->type: PT_DESKTOP);
874 hr = ResultFromShort(pt1-pt2);
876 else /* same type of pidl */
878 _ILSimpleGetText(pidl1, szTemp1, MAX_PATH);
879 _ILSimpleGetText(pidl2, szTemp2, MAX_PATH);
880 nReturn = strcasecmp(szTemp1, szTemp2);
882 if (nReturn == 0) /* first pidl different ? */
884 pidl1 = ILGetNext(pidl1);
886 if (pidl1 && pidl1->mkid.cb) /* go deeper? */
888 pidlTemp = ILCloneFirst(pidl1);
889 pidl2 = ILGetNext(pidl2);
891 hr = IShellFolder_BindToObject(iface, pidlTemp, NULL, &IID_IShellFolder, (LPVOID*)&psf);
894 nReturn = IShellFolder_CompareIDs(psf, 0, pidl1, pidl2);
895 IShellFolder_Release(psf);
896 hr = ResultFromShort(nReturn);
900 else /* no deeper on #1 */
902 pidl2 = ILGetNext(pidl2);
903 if (pidl2 && pidl2->mkid.cb) /* go deeper on #2 ? */
904 hr = ResultFromShort(-1); /* two different */
906 hr = ResultFromShort(nReturn); /* two equal simple pidls */
911 hr = ResultFromShort(nReturn); /* two different simple pidls */
916 TRACE("-- res=0x%08lx\n", hr);
920 /**************************************************************************
921 * IShellFolder_fnCreateViewObject
923 static HRESULT WINAPI IShellFolder_fnCreateViewObject(
924 IShellFolder2 * iface,
929 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
931 LPSHELLVIEW pShellView;
932 HRESULT hr = E_INVALIDARG;
934 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,debugstr_guid(riid),ppvOut);
940 if(IsEqualIID(riid, &IID_IDropTarget))
942 hr = IShellFolder_QueryInterface(iface, &IID_IDropTarget, ppvOut);
944 else if(IsEqualIID(riid, &IID_IContextMenu))
946 FIXME("IContextMenu not implemented\n");
949 else if(IsEqualIID(riid, &IID_IShellView))
951 pShellView = IShellView_Constructor((IShellFolder*)iface);
954 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
955 IShellView_Release(pShellView);
959 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
963 /**************************************************************************
964 * IShellFolder_fnGetAttributesOf
967 * UINT cidl, //[in ] num elements in pidl array
968 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
969 * ULONG* rgfInOut) //[out] result array
972 static HRESULT WINAPI IShellFolder_fnGetAttributesOf(
973 IShellFolder2 * iface,
975 LPCITEMIDLIST *apidl,
978 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
982 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n",This,cidl,apidl,*rgfInOut);
984 if ( (!cidl) || (!apidl) || (!rgfInOut))
987 while (cidl > 0 && *apidl)
990 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
995 TRACE("-- result=0x%08lx\n",*rgfInOut);
999 /**************************************************************************
1000 * IShellFolder_fnGetUIObjectOf
1003 * HWND hwndOwner, //[in ] Parent window for any output
1004 * UINT cidl, //[in ] array size
1005 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
1006 * REFIID riid, //[in ] Requested Interface
1007 * UINT* prgfInOut, //[ ] reserved
1008 * LPVOID* ppvObject) //[out] Resulting Interface
1011 * This function gets asked to return "view objects" for one or more (multiple select)
1013 * The viewobject typically is an COM object with one of the following interfaces:
1014 * IExtractIcon,IDataObject,IContextMenu
1015 * In order to support icon positions in the default Listview your DataObject
1016 * must implement the SetData method (in addition to GetData :) - the shell passes
1017 * a barely documented "Icon positions" structure to SetData when the drag starts,
1018 * and GetData's it if the drop is in another explorer window that needs the positions.
1020 static HRESULT WINAPI IShellFolder_fnGetUIObjectOf(
1021 IShellFolder2 * iface,
1024 LPCITEMIDLIST * apidl,
1029 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1032 IUnknown* pObj = NULL;
1033 HRESULT hr = E_INVALIDARG;
1035 TRACE("(%p)->(0x%04x,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
1036 This,hwndOwner,cidl,apidl,debugstr_guid(riid),prgfInOut,ppvOut);
1042 if(IsEqualIID(riid, &IID_IContextMenu) && (cidl >= 1))
1044 pObj = (LPUNKNOWN)ISvItemCm_Constructor((IShellFolder*)iface, This->absPidl, apidl, cidl);
1047 else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1))
1049 pObj = (LPUNKNOWN)IDataObject_Constructor (hwndOwner, This->absPidl, apidl, cidl);
1052 else if (IsEqualIID(riid, &IID_IExtractIconA) && (cidl == 1))
1054 pidl = ILCombine(This->absPidl,apidl[0]);
1055 pObj = (LPUNKNOWN)IExtractIconA_Constructor( pidl );
1059 else if (IsEqualIID(riid, &IID_IDropTarget) && (cidl >= 1))
1061 hr = IShellFolder_QueryInterface(iface, &IID_IDropTarget, (LPVOID*)&pObj);
1073 TRACE("(%p)->hr=0x%08lx\n",This, hr);
1077 /**************************************************************************
1078 * IShellFolder_fnGetDisplayNameOf
1079 * Retrieves the display name for the specified file object or subfolder
1082 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
1083 * DWORD dwFlags, //[in ] SHGNO formatting flags
1084 * LPSTRRET lpName) //[out] Returned display name
1087 * if the name is in the pidl the ret value should be a STRRET_OFFSET
1089 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
1090 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
1092 static HRESULT WINAPI IShellFolder_fnGetDisplayNameOf(
1093 IShellFolder2 * iface,
1098 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1100 CHAR szPath[MAX_PATH]= "";
1104 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,strRet);
1107 if(!pidl || !strRet) return E_INVALIDARG;
1109 bSimplePidl = _ILIsPidlSimple(pidl);
1111 /* take names of special folders only if its only this folder */
1112 if (_ILIsSpecialFolder(pidl))
1116 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
1121 if (!(dwFlags & SHGDN_INFOLDER) && (dwFlags & SHGDN_FORPARSING) && This->sMyPath)
1123 strcpy (szPath, This->sMyPath); /* get path to root*/
1124 PathAddBackslashA(szPath);
1125 len = strlen(szPath);
1127 _ILSimpleGetText(pidl, szPath + len, MAX_PATH - len); /* append my own path */
1130 if ( (dwFlags & SHGDN_FORPARSING) && !bSimplePidl) /* go deeper if needed */
1132 PathAddBackslashA(szPath);
1133 len = strlen(szPath);
1135 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, szPath + len, MAX_PATH - len)))
1136 return E_OUTOFMEMORY;
1138 strRet->uType = STRRET_CSTRA;
1139 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
1141 TRACE("-- (%p)->(%s)\n", This, szPath);
1145 /**************************************************************************
1146 * IShellFolder_fnSetNameOf
1147 * Changes the name of a file object or subfolder, possibly changing its item
1148 * identifier in the process.
1151 * HWND hwndOwner, //[in ] Owner window for output
1152 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
1153 * LPCOLESTR lpszName, //[in ] the items new display name
1154 * DWORD dwFlags, //[in ] SHGNO formatting flags
1155 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
1157 static HRESULT WINAPI IShellFolder_fnSetNameOf(
1158 IShellFolder2 * iface,
1160 LPCITEMIDLIST pidl, /*simple pidl*/
1163 LPITEMIDLIST *pPidlOut)
1165 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1166 char szSrc[MAX_PATH], szDest[MAX_PATH];
1168 BOOL bIsFolder = _ILIsFolder(ILFindLastID(pidl));
1170 TRACE("(%p)->(%u,pidl=%p,%s,%lu,%p)\n",
1171 This,hwndOwner,pidl,debugstr_w(lpName),dwFlags,pPidlOut);
1173 /* build source path */
1174 if (dwFlags & SHGDN_INFOLDER)
1176 strcpy(szSrc, This->sMyPath);
1177 PathAddBackslashA(szSrc);
1178 len = strlen (szSrc);
1179 _ILSimpleGetText(pidl, szSrc+len, MAX_PATH-len);
1183 SHGetPathFromIDListA(pidl, szSrc);
1186 /* build destination path */
1187 strcpy(szDest, This->sMyPath);
1188 PathAddBackslashA(szDest);
1189 len = strlen (szDest);
1190 WideCharToMultiByte( CP_ACP, 0, lpName, -1, szDest+len, MAX_PATH-len, NULL, NULL );
1191 szDest[MAX_PATH-1] = 0;
1192 TRACE("src=%s dest=%s\n", szSrc, szDest);
1193 if ( MoveFileA(szSrc, szDest) )
1195 if (pPidlOut) *pPidlOut = SHSimpleIDListFromPathA(szDest);
1196 SHChangeNotifyA( bIsFolder?SHCNE_RENAMEFOLDER:SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest);
1202 static HRESULT WINAPI IShellFolder_fnGetDefaultSearchGUID(
1203 IShellFolder2 * iface,
1206 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1207 FIXME("(%p)\n",This);
1210 static HRESULT WINAPI IShellFolder_fnEnumSearches(
1211 IShellFolder2 * iface,
1212 IEnumExtraSearch **ppenum)
1214 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1215 FIXME("(%p)\n",This);
1218 static HRESULT WINAPI IShellFolder_fnGetDefaultColumn(
1219 IShellFolder2 * iface,
1224 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1226 TRACE("(%p)\n",This);
1228 if (pSort) *pSort = 0;
1229 if (pDisplay) *pDisplay = 0;
1233 static HRESULT WINAPI IShellFolder_fnGetDefaultColumnState(
1234 IShellFolder2 * iface,
1238 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1240 TRACE("(%p)\n",This);
1242 if (!pcsFlags || iColumn >= GENERICSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1244 *pcsFlags = GenericSFHeader[iColumn].pcsFlags;
1248 static HRESULT WINAPI IShellFolder_fnGetDetailsEx(
1249 IShellFolder2 * iface,
1251 const SHCOLUMNID *pscid,
1254 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1255 FIXME("(%p)\n",This);
1259 static HRESULT WINAPI IShellFolder_fnGetDetailsOf(
1260 IShellFolder2 * iface,
1265 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1266 HRESULT hr = E_FAIL;
1268 TRACE("(%p)->(%p %i %p)\n",This, pidl, iColumn, psd);
1270 if (!psd || iColumn >= GENERICSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1274 /* the header titles */
1275 psd->fmt = GenericSFHeader[iColumn].fmt;
1276 psd->cxChar = GenericSFHeader[iColumn].cxChar;
1277 psd->str.uType = STRRET_CSTRA;
1278 LoadStringA(shell32_hInstance, GenericSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
1283 /* the data from the pidl */
1287 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
1290 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
1293 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
1296 _ILGetFileDate(pidl, psd->str.u.cStr, MAX_PATH);
1298 case 4: /* attributes */
1299 _ILGetFileAttributes(pidl, psd->str.u.cStr, MAX_PATH);
1303 psd->str.uType = STRRET_CSTRA;
1308 static HRESULT WINAPI IShellFolder_fnMapNameToSCID(
1309 IShellFolder2 * iface,
1313 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1314 FIXME("(%p)\n",This);
1318 static ICOM_VTABLE(IShellFolder2) sfvt =
1320 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1321 IShellFolder_fnQueryInterface,
1322 IShellFolder_fnAddRef,
1323 IShellFolder_fnRelease,
1324 IShellFolder_fnParseDisplayName,
1325 IShellFolder_fnEnumObjects,
1326 IShellFolder_fnBindToObject,
1327 IShellFolder_fnBindToStorage,
1328 IShellFolder_fnCompareIDs,
1329 IShellFolder_fnCreateViewObject,
1330 IShellFolder_fnGetAttributesOf,
1331 IShellFolder_fnGetUIObjectOf,
1332 IShellFolder_fnGetDisplayNameOf,
1333 IShellFolder_fnSetNameOf,
1336 IShellFolder_fnGetDefaultSearchGUID,
1337 IShellFolder_fnEnumSearches,
1338 IShellFolder_fnGetDefaultColumn,
1339 IShellFolder_fnGetDefaultColumnState,
1340 IShellFolder_fnGetDetailsEx,
1341 IShellFolder_fnGetDetailsOf,
1342 IShellFolder_fnMapNameToSCID
1345 /****************************************************************************
1346 * ISFHelper for IShellFolder implementation
1349 static HRESULT WINAPI ISFHelper_fnQueryInterface(
1354 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1356 TRACE("(%p)\n", This);
1358 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObj);
1361 static ULONG WINAPI ISFHelper_fnAddRef(
1364 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1366 TRACE("(%p)\n", This);
1368 return IUnknown_AddRef(This->pUnkOuter);
1371 static ULONG WINAPI ISFHelper_fnRelease(
1374 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1376 TRACE("(%p)\n", This);
1378 return IUnknown_Release(This->pUnkOuter);
1382 /****************************************************************************
1383 * ISFHelper_fnAddFolder
1385 * creates a unique folder name
1388 static HRESULT WINAPI ISFHelper_fnGetUniqueName(
1393 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
1394 IEnumIDList * penum;
1396 char szText[MAX_PATH];
1397 char * szNewFolder = "New Folder";
1399 TRACE("(%p)(%s %u)\n", This, lpName, uLen);
1401 if (uLen < strlen(szNewFolder) + 4) return E_POINTER;
1403 strcpy(lpName, szNewFolder);
1405 hr = IShellFolder_fnEnumObjects(_IShellFolder2_(This), 0, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &penum);
1412 next: IEnumIDList_Reset(penum);
1413 while(S_OK == IEnumIDList_Next(penum, 1, &pidl, &dwFetched) && dwFetched)
1415 _ILSimpleGetText(pidl, szText, MAX_PATH);
1416 if (0 == strcasecmp(szText, lpName))
1418 sprintf(lpName, "%s %d", szNewFolder, i++);
1428 IEnumIDList_Release(penum);
1433 /****************************************************************************
1434 * ISFHelper_fnAddFolder
1436 * adds a new folder.
1439 static HRESULT WINAPI ISFHelper_fnAddFolder(
1443 LPITEMIDLIST* ppidlOut)
1445 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
1446 char lpstrNewDir[MAX_PATH];
1448 HRESULT hres = E_FAIL;
1450 TRACE("(%p)(%s %p)\n", This, lpName, ppidlOut);
1452 strcpy(lpstrNewDir, This->sMyPath);
1453 PathAddBackslashA(lpstrNewDir);
1454 strcat(lpstrNewDir, lpName);
1456 bRes = CreateDirectoryA(lpstrNewDir, NULL);
1460 LPITEMIDLIST pidl, pidlitem;
1462 pidlitem = SHSimpleIDListFromPathA(lpstrNewDir);
1464 pidl = ILCombine(This->absPidl, pidlitem);
1465 SHChangeNotifyA(SHCNE_MKDIR, SHCNF_IDLIST, pidl, NULL);
1468 if (ppidlOut) *ppidlOut = pidlitem;
1473 char lpstrText[128+MAX_PATH];
1474 char lpstrTempText[128];
1475 char lpstrCaption[256];
1477 /* Cannot Create folder because of permissions */
1478 LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_DENIED, lpstrTempText, sizeof(lpstrTempText));
1479 LoadStringA(shell32_hInstance, IDS_CREATEFOLDER_CAPTION, lpstrCaption, sizeof(lpstrCaption));
1480 sprintf(lpstrText,lpstrTempText, lpstrNewDir);
1481 MessageBoxA(hwnd,lpstrText, lpstrCaption, MB_OK | MB_ICONEXCLAMATION);
1487 /****************************************************************************
1488 * ISFHelper_fnDeleteItems
1490 * deletes items in folder
1492 static HRESULT WINAPI ISFHelper_fnDeleteItems(
1495 LPCITEMIDLIST* apidl)
1497 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
1499 char szPath[MAX_PATH];
1500 BOOL bConfirm = TRUE;
1502 TRACE("(%p)(%u %p)\n", This, cidl, apidl);
1504 /* deleting multiple items so give a slightly different warning */
1508 snprintf(tmp, sizeof(tmp), "%d", cidl);
1509 if(!SHELL_WarnItemDelete(ASK_DELETE_MULTIPLE_ITEM, tmp))
1514 for(i=0; i< cidl; i++)
1516 strcpy(szPath, This->sMyPath);
1517 PathAddBackslashA(szPath);
1518 _ILSimpleGetText(apidl[i], szPath+strlen(szPath), MAX_PATH);
1520 if (_ILIsFolder(apidl[i]))
1523 TRACE("delete %s\n", szPath);
1524 if (! SHELL_DeleteDirectoryA(szPath, bConfirm))
1526 TRACE("delete %s failed, bConfirm=%d\n", szPath, bConfirm);
1529 pidl = ILCombine(This->absPidl, apidl[i]);
1530 SHChangeNotifyA(SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL);
1533 else if (_ILIsValue(apidl[i]))
1537 TRACE("delete %s\n", szPath);
1538 if (! SHELL_DeleteFileA(szPath, bConfirm))
1540 TRACE("delete %s failed, bConfirm=%d\n", szPath, bConfirm);
1543 pidl = ILCombine(This->absPidl, apidl[i]);
1544 SHChangeNotifyA(SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL);
1552 /****************************************************************************
1553 * ISFHelper_fnCopyItems
1555 * copies items to this folder
1557 static HRESULT WINAPI ISFHelper_fnCopyItems(
1559 IShellFolder* pSFFrom,
1561 LPCITEMIDLIST *apidl)
1564 IPersistFolder2 * ppf2=NULL;
1565 char szSrcPath[MAX_PATH], szDstPath[MAX_PATH];
1566 _ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface);
1568 TRACE("(%p)->(%p,%u,%p)\n", This, pSFFrom, cidl, apidl);
1570 IShellFolder_QueryInterface(pSFFrom, &IID_IPersistFolder2, (LPVOID*)&ppf2);
1574 if (SUCCEEDED(IPersistFolder2_GetCurFolder(ppf2, &pidl)))
1576 for (i=0; i<cidl; i++)
1578 SHGetPathFromIDListA(pidl, szSrcPath);
1579 PathAddBackslashA(szSrcPath);
1580 _ILSimpleGetText(apidl[i], szSrcPath+strlen(szSrcPath), MAX_PATH);
1582 strcpy(szDstPath, This->sMyPath);
1583 PathAddBackslashA(szDstPath);
1584 _ILSimpleGetText(apidl[i], szDstPath+strlen(szDstPath), MAX_PATH);
1585 MESSAGE("would copy %s to %s\n", szSrcPath, szDstPath);
1589 IPersistFolder2_Release(ppf2);
1594 static ICOM_VTABLE(ISFHelper) shvt =
1596 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1597 ISFHelper_fnQueryInterface,
1599 ISFHelper_fnRelease,
1600 ISFHelper_fnGetUniqueName,
1601 ISFHelper_fnAddFolder,
1602 ISFHelper_fnDeleteItems,
1603 ISFHelper_fnCopyItems,
1606 /***********************************************************************
1607 * [Desktopfolder] IShellFolder implementation
1609 static struct ICOM_VTABLE(IShellFolder2) sfdvt;
1611 static shvheader DesktopSFHeader [] =
1613 { IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
1614 { IDS_SHV_COLUMN2, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
1615 { IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
1616 { IDS_SHV_COLUMN4, SHCOLSTATE_TYPE_DATE | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 12 },
1617 { IDS_SHV_COLUMN5, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 5 }
1619 #define DESKTOPSHELLVIEWCOLUMNS 5
1621 /**************************************************************************
1622 * ISF_Desktop_Constructor
1625 IShellFolder * ISF_Desktop_Constructor()
1627 IGenericSFImpl * sf;
1629 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
1631 ICOM_VTBL(sf)=&unkvt;
1632 sf->lpvtblShellFolder=&sfdvt;
1633 sf->absPidl=_ILCreateDesktop(); /* my qualified pidl */
1634 sf->pUnkOuter = (IUnknown *) &sf->lpVtbl;
1639 return _IShellFolder_(sf);
1642 /**************************************************************************
1643 * ISF_Desktop_fnQueryInterface
1645 * NOTES supports not IPersist/IPersistFolder
1647 static HRESULT WINAPI ISF_Desktop_fnQueryInterface(
1648 IShellFolder2 * iface,
1652 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1654 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
1658 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
1660 *ppvObj = _IUnknown_(This);
1662 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
1664 *ppvObj = _IShellFolder_(This);
1666 else if(IsEqualIID(riid, &IID_IShellFolder2)) /*IShellFolder2*/
1668 *ppvObj = _IShellFolder_(This);
1673 IUnknown_AddRef((IUnknown*)(*ppvObj));
1674 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
1677 TRACE("-- Interface: E_NOINTERFACE\n");
1678 return E_NOINTERFACE;
1681 /**************************************************************************
1682 * ISF_Desktop_fnParseDisplayName
1685 * "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" and "" binds
1688 static HRESULT WINAPI ISF_Desktop_fnParseDisplayName(
1689 IShellFolder2 * iface,
1692 LPOLESTR lpszDisplayName,
1694 LPITEMIDLIST *ppidl,
1695 DWORD *pdwAttributes)
1697 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1699 LPCWSTR szNext=NULL;
1700 LPITEMIDLIST pidlTemp=NULL;
1701 HRESULT hr=E_OUTOFMEMORY;
1703 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
1704 This,hwndOwner,pbcReserved,lpszDisplayName,
1705 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
1708 if (pchEaten) *pchEaten = 0; /* strange but like the original */
1710 /* fixme no real parsing implemented */
1711 pidlTemp = _ILCreateMyComputer();
1712 szNext = lpszDisplayName;
1714 if (szNext && *szNext)
1716 hr = SHELL32_ParseNextElement(hwndOwner, iface, &pidlTemp, (LPOLESTR)szNext, pchEaten, pdwAttributes);
1722 if (pdwAttributes && *pdwAttributes)
1724 SHELL32_GetItemAttributes(_IShellFolder_(This), pidlTemp, pdwAttributes);
1730 TRACE("(%p)->(-- ret=0x%08lx)\n", This, hr);
1735 /**************************************************************************
1736 * ISF_Desktop_fnEnumObjects
1738 static HRESULT WINAPI ISF_Desktop_fnEnumObjects(
1739 IShellFolder2 * iface,
1742 LPENUMIDLIST* ppEnumIDList)
1744 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1746 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
1748 *ppEnumIDList = NULL;
1749 *ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_DESK);
1751 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
1753 if(!*ppEnumIDList) return E_OUTOFMEMORY;
1758 /**************************************************************************
1759 * ISF_Desktop_fnBindToObject
1761 static HRESULT WINAPI ISF_Desktop_fnBindToObject( IShellFolder2 * iface, LPCITEMIDLIST pidl,
1762 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
1764 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1766 IShellFolder *pShellFolder, *pSubFolder;
1768 TRACE("(%p)->(pidl=%p,%p,\n\tIID:\t%s,%p)\n",
1769 This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
1773 if ((clsid=_ILGetGUIDPointer(pidl)))
1775 if ( IsEqualIID(clsid, &CLSID_MyComputer))
1777 pShellFolder = ISF_MyComputer_Constructor();
1781 /* shell extension */
1782 if (!SUCCEEDED(SHELL32_CoCreateInitSF (This->absPidl, pidl, clsid, riid, (LPVOID*)&pShellFolder)))
1784 return E_INVALIDARG;
1790 /* file system folder on the desktop */
1791 LPITEMIDLIST deskpidl, firstpidl, completepidl;
1792 IPersistFolder * ppf;
1795 SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, &deskpidl);
1796 firstpidl = ILCloneFirst(pidl);
1797 completepidl = ILCombine(deskpidl, firstpidl);
1799 pShellFolder = IShellFolder_Constructor(NULL, NULL);
1800 if (SUCCEEDED(IShellFolder_QueryInterface(pShellFolder, &IID_IPersistFolder, (LPVOID*)&ppf)))
1802 IPersistFolder_Initialize(ppf, completepidl);
1803 IPersistFolder_Release(ppf);
1805 ILFree(completepidl);
1810 if (_ILIsPidlSimple(pidl)) /* no sub folders */
1812 *ppvOut = pShellFolder;
1814 else /* go deeper */
1816 IShellFolder_BindToObject(pShellFolder, ILGetNext(pidl), NULL, riid, (LPVOID)&pSubFolder);
1817 IShellFolder_Release(pShellFolder);
1818 *ppvOut = pSubFolder;
1821 TRACE("-- (%p) returning (%p)\n",This, *ppvOut);
1826 /**************************************************************************
1827 * ISF_Desktop_fnCreateViewObject
1829 static HRESULT WINAPI ISF_Desktop_fnCreateViewObject( IShellFolder2 * iface,
1830 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
1832 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1834 LPSHELLVIEW pShellView;
1835 HRESULT hr = E_INVALIDARG;
1837 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,debugstr_guid(riid),ppvOut);
1843 if(IsEqualIID(riid, &IID_IDropTarget))
1845 WARN("IDropTarget not implemented\n");
1848 else if(IsEqualIID(riid, &IID_IContextMenu))
1850 WARN("IContextMenu not implemented\n");
1853 else if(IsEqualIID(riid, &IID_IShellView))
1855 pShellView = IShellView_Constructor((IShellFolder*)iface);
1858 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
1859 IShellView_Release(pShellView);
1863 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
1867 /**************************************************************************
1868 * ISF_Desktop_fnGetAttributesOf
1870 static HRESULT WINAPI ISF_Desktop_fnGetAttributesOf(
1871 IShellFolder2 * iface,
1873 LPCITEMIDLIST *apidl,
1876 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1880 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n",This,cidl,apidl, *rgfInOut);
1882 if ( (!cidl) || (!apidl) || (!rgfInOut))
1883 return E_INVALIDARG;
1885 while (cidl > 0 && *apidl)
1888 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
1893 TRACE("-- result=0x%08lx\n",*rgfInOut);
1898 /**************************************************************************
1899 * ISF_Desktop_fnGetDisplayNameOf
1902 * special case: pidl = null gives desktop-name back
1904 static HRESULT WINAPI ISF_Desktop_fnGetDisplayNameOf(
1905 IShellFolder2 * iface,
1910 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1912 CHAR szPath[MAX_PATH]= "";
1914 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,strRet);
1917 if(!strRet) return E_INVALIDARG;
1921 HCR_GetClassName(&CLSID_ShellDesktop, szPath, MAX_PATH);
1923 else if ( _ILIsPidlSimple(pidl) )
1925 _ILSimpleGetText(pidl, szPath, MAX_PATH);
1929 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, szPath, MAX_PATH)))
1930 return E_OUTOFMEMORY;
1932 strRet->uType = STRRET_CSTRA;
1933 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
1936 TRACE("-- (%p)->(%s)\n", This, szPath);
1940 static HRESULT WINAPI ISF_Desktop_fnGetDefaultSearchGUID(
1941 IShellFolder2 * iface,
1944 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1945 FIXME("(%p)\n",This);
1948 static HRESULT WINAPI ISF_Desktop_fnEnumSearches(
1949 IShellFolder2 * iface,
1950 IEnumExtraSearch **ppenum)
1952 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1953 FIXME("(%p)\n",This);
1956 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumn(
1957 IShellFolder2 * iface,
1962 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1964 TRACE("(%p)\n",This);
1966 if (pSort) *pSort = 0;
1967 if (pDisplay) *pDisplay = 0;
1971 static HRESULT WINAPI ISF_Desktop_fnGetDefaultColumnState(
1972 IShellFolder2 * iface,
1976 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1978 TRACE("(%p)\n",This);
1980 if (!pcsFlags || iColumn >= DESKTOPSHELLVIEWCOLUMNS ) return E_INVALIDARG;
1982 *pcsFlags = DesktopSFHeader[iColumn].pcsFlags;
1986 static HRESULT WINAPI ISF_Desktop_fnGetDetailsEx(
1987 IShellFolder2 * iface,
1989 const SHCOLUMNID *pscid,
1992 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
1993 FIXME("(%p)\n",This);
1997 static HRESULT WINAPI ISF_Desktop_fnGetDetailsOf(
1998 IShellFolder2 * iface,
2003 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2004 HRESULT hr = E_FAIL;;
2006 TRACE("(%p)->(%p %i %p)\n",This, pidl, iColumn, psd);
2008 if (!psd || iColumn >= DESKTOPSHELLVIEWCOLUMNS ) return E_INVALIDARG;
2012 psd->fmt = DesktopSFHeader[iColumn].fmt;
2013 psd->cxChar = DesktopSFHeader[iColumn].cxChar;
2014 psd->str.uType = STRRET_CSTRA;
2015 LoadStringA(shell32_hInstance, DesktopSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
2020 /* the data from the pidl */
2024 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
2027 _ILGetFileSize (pidl, psd->str.u.cStr, MAX_PATH);
2030 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
2033 _ILGetFileDate(pidl, psd->str.u.cStr, MAX_PATH);
2035 case 4: /* attributes */
2036 _ILGetFileAttributes(pidl, psd->str.u.cStr, MAX_PATH);
2040 psd->str.uType = STRRET_CSTRA;
2045 static HRESULT WINAPI ISF_Desktop_fnMapNameToSCID(
2046 IShellFolder2 * iface,
2050 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2051 FIXME("(%p)\n",This);
2055 static ICOM_VTABLE(IShellFolder2) sfdvt =
2057 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2058 ISF_Desktop_fnQueryInterface,
2059 IShellFolder_fnAddRef,
2060 IShellFolder_fnRelease,
2061 ISF_Desktop_fnParseDisplayName,
2062 ISF_Desktop_fnEnumObjects,
2063 ISF_Desktop_fnBindToObject,
2064 IShellFolder_fnBindToStorage,
2065 IShellFolder_fnCompareIDs,
2066 ISF_Desktop_fnCreateViewObject,
2067 ISF_Desktop_fnGetAttributesOf,
2068 IShellFolder_fnGetUIObjectOf,
2069 ISF_Desktop_fnGetDisplayNameOf,
2070 IShellFolder_fnSetNameOf,
2073 ISF_Desktop_fnGetDefaultSearchGUID,
2074 ISF_Desktop_fnEnumSearches,
2075 ISF_Desktop_fnGetDefaultColumn,
2076 ISF_Desktop_fnGetDefaultColumnState,
2077 ISF_Desktop_fnGetDetailsEx,
2078 ISF_Desktop_fnGetDetailsOf,
2079 ISF_Desktop_fnMapNameToSCID
2083 /***********************************************************************
2084 * IShellFolder [MyComputer] implementation
2087 static struct ICOM_VTABLE(IShellFolder2) sfmcvt;
2089 static shvheader MyComputerSFHeader [] =
2091 { IDS_SHV_COLUMN1, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15 },
2092 { IDS_SHV_COLUMN3, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
2093 { IDS_SHV_COLUMN6, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
2094 { IDS_SHV_COLUMN7, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 10 },
2096 #define MYCOMPUTERSHELLVIEWCOLUMNS 4
2098 /**************************************************************************
2099 * ISF_MyComputer_Constructor
2101 static IShellFolder * ISF_MyComputer_Constructor(void)
2103 IGenericSFImpl * sf;
2105 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IGenericSFImpl));
2108 ICOM_VTBL(sf)=&unkvt;
2109 sf->lpvtblShellFolder=&sfmcvt;
2110 sf->lpvtblPersistFolder2 = &psfvt;
2111 sf->pclsid = (CLSID*)&CLSID_SFMyComp;
2112 sf->absPidl=_ILCreateMyComputer(); /* my qualified pidl */
2113 sf->pUnkOuter = (IUnknown *) &sf->lpVtbl;
2118 return _IShellFolder_(sf);
2121 /**************************************************************************
2122 * ISF_MyComputer_fnParseDisplayName
2124 static HRESULT WINAPI ISF_MyComputer_fnParseDisplayName(
2125 IShellFolder2 * iface,
2128 LPOLESTR lpszDisplayName,
2130 LPITEMIDLIST *ppidl,
2131 DWORD *pdwAttributes)
2133 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2135 HRESULT hr = E_OUTOFMEMORY;
2136 LPCWSTR szNext=NULL;
2137 WCHAR szElement[MAX_PATH];
2138 CHAR szTempA[MAX_PATH];
2139 LPITEMIDLIST pidlTemp;
2141 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
2142 This,hwndOwner,pbcReserved,lpszDisplayName,
2143 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
2146 if (pchEaten) *pchEaten = 0; /* strange but like the original */
2148 /* do we have an absolute path name ? */
2149 if (PathGetDriveNumberW(lpszDisplayName) >= 0 &&
2150 lpszDisplayName[2] == (WCHAR)'\\')
2152 szNext = GetNextElementW(lpszDisplayName, szElement, MAX_PATH);
2153 WideCharToMultiByte( CP_ACP, 0, szElement, -1, szTempA, MAX_PATH, NULL, NULL );
2154 pidlTemp = _ILCreateDrive(szTempA);
2156 if (szNext && *szNext)
2158 hr = SHELL32_ParseNextElement(hwndOwner, iface, &pidlTemp, (LPOLESTR)szNext, pchEaten, pdwAttributes);
2162 if (pdwAttributes && *pdwAttributes)
2164 SHELL32_GetItemAttributes(_IShellFolder_(This), pidlTemp, pdwAttributes);
2171 TRACE("(%p)->(-- ret=0x%08lx)\n", This, hr);
2176 /**************************************************************************
2177 * ISF_MyComputer_fnEnumObjects
2179 static HRESULT WINAPI ISF_MyComputer_fnEnumObjects(
2180 IShellFolder2 * iface,
2183 LPENUMIDLIST* ppEnumIDList)
2185 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2187 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
2189 *ppEnumIDList = NULL;
2190 *ppEnumIDList = IEnumIDList_Constructor (NULL, dwFlags, EIDL_MYCOMP);
2192 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
2194 if(!*ppEnumIDList) return E_OUTOFMEMORY;
2199 /**************************************************************************
2200 * ISF_MyComputer_fnBindToObject
2202 static HRESULT WINAPI ISF_MyComputer_fnBindToObject( IShellFolder2 * iface, LPCITEMIDLIST pidl,
2203 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
2205 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2207 IShellFolder *pShellFolder, *pSubFolder;
2208 LPITEMIDLIST pidltemp;
2210 TRACE("(%p)->(pidl=%p,%p,\n\tIID:\t%s,%p)\n",
2211 This,pidl,pbcReserved,debugstr_guid(riid),ppvOut);
2213 if(!pidl || !ppvOut) return E_INVALIDARG;
2217 if ((clsid=_ILGetGUIDPointer(pidl)) && !IsEqualIID(clsid, &CLSID_MyComputer))
2219 if (!SUCCEEDED(SHELL32_CoCreateInitSF (This->absPidl, pidl, clsid, riid, (LPVOID*)&pShellFolder)))
2226 if (!_ILIsDrive(pidl)) return E_INVALIDARG;
2228 pidltemp = ILCloneFirst(pidl);
2229 pShellFolder = IShellFolder_Constructor(iface, pidltemp);
2233 if (_ILIsPidlSimple(pidl)) /* no sub folders */
2235 *ppvOut = pShellFolder;
2237 else /* go deeper */
2239 IShellFolder_BindToObject(pShellFolder, ILGetNext(pidl), NULL, &IID_IShellFolder, (LPVOID)&pSubFolder);
2240 IShellFolder_Release(pShellFolder);
2241 *ppvOut = pSubFolder;
2244 TRACE("-- (%p) returning (%p)\n",This, *ppvOut);
2249 /**************************************************************************
2250 * ISF_MyComputer_fnCreateViewObject
2252 static HRESULT WINAPI ISF_MyComputer_fnCreateViewObject( IShellFolder2 * iface,
2253 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
2255 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2257 LPSHELLVIEW pShellView;
2258 HRESULT hr = E_INVALIDARG;
2260 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,debugstr_guid(riid),ppvOut);
2266 if(IsEqualIID(riid, &IID_IDropTarget))
2268 WARN("IDropTarget not implemented\n");
2271 else if(IsEqualIID(riid, &IID_IContextMenu))
2273 WARN("IContextMenu not implemented\n");
2276 else if(IsEqualIID(riid, &IID_IShellView))
2278 pShellView = IShellView_Constructor((IShellFolder*)iface);
2281 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
2282 IShellView_Release(pShellView);
2286 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
2290 /**************************************************************************
2291 * ISF_MyComputer_fnGetAttributesOf
2293 static HRESULT WINAPI ISF_MyComputer_fnGetAttributesOf(
2294 IShellFolder2 * iface,
2296 LPCITEMIDLIST *apidl,
2299 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2303 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n",This,cidl,apidl,*rgfInOut);
2305 if ( (!cidl) || (!apidl) || (!rgfInOut))
2306 return E_INVALIDARG;
2308 while (cidl > 0 && *apidl)
2311 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
2316 TRACE("-- result=0x%08lx\n",*rgfInOut);
2320 /**************************************************************************
2321 * ISF_MyComputer_fnGetDisplayNameOf
2324 * The desktopfolder creates only complete paths (SHGDN_FORPARSING).
2325 * SHGDN_INFOLDER makes no sense.
2327 static HRESULT WINAPI ISF_MyComputer_fnGetDisplayNameOf(
2328 IShellFolder2 * iface,
2333 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2335 char szPath[MAX_PATH], szDrive[18];
2339 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,strRet);
2342 if(!strRet) return E_INVALIDARG;
2344 szPath[0]=0x00; szDrive[0]=0x00;
2347 bSimplePidl = _ILIsPidlSimple(pidl);
2349 if (_ILIsSpecialFolder(pidl))
2351 /* take names of special folders only if its only this folder */
2354 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
2359 if (!_ILIsDrive(pidl))
2361 ERR("Wrong pidl type\n");
2362 return E_INVALIDARG;
2365 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
2367 /* long view "lw_name (C:)" */
2368 if ( bSimplePidl && !(dwFlags & SHGDN_FORPARSING))
2370 DWORD dwVolumeSerialNumber,dwMaximumComponetLength,dwFileSystemFlags;
2372 GetVolumeInformationA(szPath,szDrive,12,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
2373 strcat (szDrive," (");
2374 strncat (szDrive, szPath, 2);
2375 strcat (szDrive,")");
2376 strcpy (szPath, szDrive);
2380 if (!bSimplePidl) /* go deeper if needed */
2382 PathAddBackslashA(szPath);
2383 len = strlen(szPath);
2385 if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_FORPARSING, szPath + len, MAX_PATH - len)))
2386 return E_OUTOFMEMORY;
2388 strRet->uType = STRRET_CSTRA;
2389 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
2392 TRACE("-- (%p)->(%s)\n", This, szPath);
2396 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultSearchGUID(
2397 IShellFolder2 * iface,
2400 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2401 FIXME("(%p)\n",This);
2404 static HRESULT WINAPI ISF_MyComputer_fnEnumSearches(
2405 IShellFolder2 * iface,
2406 IEnumExtraSearch **ppenum)
2408 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2409 FIXME("(%p)\n",This);
2412 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumn(
2413 IShellFolder2 * iface,
2418 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2420 TRACE("(%p)\n",This);
2422 if (pSort) *pSort = 0;
2423 if (pDisplay) *pDisplay = 0;
2427 static HRESULT WINAPI ISF_MyComputer_fnGetDefaultColumnState(
2428 IShellFolder2 * iface,
2432 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2434 TRACE("(%p)\n",This);
2436 if (!pcsFlags || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS ) return E_INVALIDARG;
2438 *pcsFlags = MyComputerSFHeader[iColumn].pcsFlags;
2442 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsEx(
2443 IShellFolder2 * iface,
2445 const SHCOLUMNID *pscid,
2448 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2449 FIXME("(%p)\n",This);
2454 /* fixme: drive size >4GB is rolling over */
2455 static HRESULT WINAPI ISF_MyComputer_fnGetDetailsOf(
2456 IShellFolder2 * iface,
2461 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2464 TRACE("(%p)->(%p %i %p)\n",This, pidl, iColumn, psd);
2466 if (!psd || iColumn >= MYCOMPUTERSHELLVIEWCOLUMNS ) return E_INVALIDARG;
2470 psd->fmt = MyComputerSFHeader[iColumn].fmt;
2471 psd->cxChar = MyComputerSFHeader[iColumn].cxChar;
2472 psd->str.uType = STRRET_CSTRA;
2473 LoadStringA(shell32_hInstance, MyComputerSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
2478 char szPath[MAX_PATH];
2479 ULARGE_INTEGER ulBytes;
2481 psd->str.u.cStr[0] = 0x00;
2482 psd->str.uType = STRRET_CSTRA;
2486 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
2489 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
2491 case 2: /* total size */
2492 if (_ILIsDrive(pidl))
2494 _ILSimpleGetText(pidl, szPath, MAX_PATH);
2495 GetDiskFreeSpaceExA(szPath, NULL, &ulBytes, NULL);
2496 StrFormatByteSizeA(ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
2499 case 3: /* free size */
2500 if (_ILIsDrive(pidl))
2502 _ILSimpleGetText(pidl, szPath, MAX_PATH);
2503 GetDiskFreeSpaceExA(szPath, &ulBytes, NULL, NULL);
2504 StrFormatByteSizeA(ulBytes.s.LowPart, psd->str.u.cStr, MAX_PATH);
2513 static HRESULT WINAPI ISF_MyComputer_fnMapNameToSCID(
2514 IShellFolder2 * iface,
2518 _ICOM_THIS_From_IShellFolder2(IGenericSFImpl, iface)
2519 FIXME("(%p)\n",This);
2523 static ICOM_VTABLE(IShellFolder2) sfmcvt =
2525 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2526 IShellFolder_fnQueryInterface,
2527 IShellFolder_fnAddRef,
2528 IShellFolder_fnRelease,
2529 ISF_MyComputer_fnParseDisplayName,
2530 ISF_MyComputer_fnEnumObjects,
2531 ISF_MyComputer_fnBindToObject,
2532 IShellFolder_fnBindToStorage,
2533 IShellFolder_fnCompareIDs,
2534 ISF_MyComputer_fnCreateViewObject,
2535 ISF_MyComputer_fnGetAttributesOf,
2536 IShellFolder_fnGetUIObjectOf,
2537 ISF_MyComputer_fnGetDisplayNameOf,
2538 IShellFolder_fnSetNameOf,
2541 ISF_MyComputer_fnGetDefaultSearchGUID,
2542 ISF_MyComputer_fnEnumSearches,
2543 ISF_MyComputer_fnGetDefaultColumn,
2544 ISF_MyComputer_fnGetDefaultColumnState,
2545 ISF_MyComputer_fnGetDetailsEx,
2546 ISF_MyComputer_fnGetDetailsOf,
2547 ISF_MyComputer_fnMapNameToSCID
2551 /************************************************************************
2552 * ISFPersistFolder_QueryInterface (IUnknown)
2555 static HRESULT WINAPI ISFPersistFolder2_QueryInterface(
2556 IPersistFolder2 * iface,
2560 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2562 TRACE("(%p)\n", This);
2564 return IUnknown_QueryInterface(This->pUnkOuter, iid, ppvObj);
2567 /************************************************************************
2568 * ISFPersistFolder_AddRef (IUnknown)
2571 static ULONG WINAPI ISFPersistFolder2_AddRef(
2572 IPersistFolder2 * iface)
2574 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2576 TRACE("(%p)\n", This);
2578 return IUnknown_AddRef(This->pUnkOuter);
2581 /************************************************************************
2582 * ISFPersistFolder_Release (IUnknown)
2585 static ULONG WINAPI ISFPersistFolder2_Release(
2586 IPersistFolder2 * iface)
2588 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2590 TRACE("(%p)\n", This);
2592 return IUnknown_Release(This->pUnkOuter);
2595 /************************************************************************
2596 * ISFPersistFolder_GetClassID (IPersist)
2598 static HRESULT WINAPI ISFPersistFolder2_GetClassID(
2599 IPersistFolder2 * iface,
2602 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2604 TRACE("(%p)\n", This);
2606 if (!lpClassId) return E_POINTER;
2607 *lpClassId = *This->pclsid;
2612 /************************************************************************
2613 * ISFPersistFolder_Initialize (IPersistFolder)
2616 * sMyPath is not set. Don't know how to handle in a non rooted environment.
2618 static HRESULT WINAPI ISFPersistFolder2_Initialize(
2619 IPersistFolder2 * iface,
2622 char sTemp[MAX_PATH];
2623 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2625 TRACE("(%p)->(%p)\n", This, pidl);
2627 /* free the old stuff */
2630 SHFree(This->absPidl);
2631 This->absPidl = NULL;
2635 SHFree(This->sMyPath);
2636 This->sMyPath = NULL;
2640 This->absPidl = ILClone(pidl);
2643 if (SHGetPathFromIDListA(pidl, sTemp))
2645 This->sMyPath = SHAlloc(strlen(sTemp)+1);
2646 strcpy(This->sMyPath, sTemp);
2649 TRACE("--(%p)->(%s)\n", This, This->sMyPath);
2654 /**************************************************************************
2655 * IPersistFolder2_fnGetCurFolder
2657 static HRESULT WINAPI ISFPersistFolder2_fnGetCurFolder(
2658 IPersistFolder2 * iface,
2659 LPITEMIDLIST * pidl)
2661 _ICOM_THIS_From_IPersistFolder2(IGenericSFImpl, iface);
2663 TRACE("(%p)->(%p)\n",This, pidl);
2665 if (!pidl) return E_POINTER;
2667 *pidl = ILClone(This->absPidl);
2672 static ICOM_VTABLE(IPersistFolder2) psfvt =
2674 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2675 ISFPersistFolder2_QueryInterface,
2676 ISFPersistFolder2_AddRef,
2677 ISFPersistFolder2_Release,
2678 ISFPersistFolder2_GetClassID,
2679 ISFPersistFolder2_Initialize,
2680 ISFPersistFolder2_fnGetCurFolder
2683 /****************************************************************************
2684 * ISFDropTarget implementation
2686 static BOOL ISFDropTarget_QueryDrop(
2691 DWORD dwEffect = *pdwEffect;
2693 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2695 *pdwEffect = DROPEFFECT_NONE;
2697 if (This->fAcceptFmt)
2698 { /* Does our interpretation of the keystate ... */
2699 *pdwEffect = KeyStateToDropEffect(dwKeyState);
2701 /* ... matches the desired effect ? */
2702 if (dwEffect & *pdwEffect)
2710 static HRESULT WINAPI ISFDropTarget_QueryInterface(
2715 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2717 TRACE("(%p)\n", This);
2719 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObj);
2722 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
2724 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2726 TRACE("(%p)\n", This);
2728 return IUnknown_AddRef(This->pUnkOuter);
2731 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
2733 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2735 TRACE("(%p)\n", This);
2737 return IUnknown_Release(This->pUnkOuter);
2740 static HRESULT WINAPI ISFDropTarget_DragEnter(
2742 IDataObject *pDataObject,
2749 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2751 TRACE("(%p)->(DataObject=%p)\n",This,pDataObject);
2753 InitFormatEtc(fmt, This->cfShellIDList, TYMED_HGLOBAL);
2755 This->fAcceptFmt = (S_OK == IDataObject_QueryGetData(pDataObject, &fmt)) ? TRUE : FALSE;
2757 ISFDropTarget_QueryDrop(iface, dwKeyState, pdwEffect);
2762 static HRESULT WINAPI ISFDropTarget_DragOver(
2768 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2770 TRACE("(%p)\n",This);
2772 if(!pdwEffect) return E_INVALIDARG;
2774 ISFDropTarget_QueryDrop(iface, dwKeyState, pdwEffect);
2779 static HRESULT WINAPI ISFDropTarget_DragLeave(
2782 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2784 TRACE("(%p)\n",This);
2786 This->fAcceptFmt = FALSE;
2791 static HRESULT WINAPI ISFDropTarget_Drop(
2793 IDataObject* pDataObject,
2798 _ICOM_THIS_From_IDropTarget(IGenericSFImpl,iface);
2800 FIXME("(%p) object dropped\n",This);
2805 static struct ICOM_VTABLE(IDropTarget) dtvt =
2807 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
2808 ISFDropTarget_QueryInterface,
2809 ISFDropTarget_AddRef,
2810 ISFDropTarget_Release,
2811 ISFDropTarget_DragEnter,
2812 ISFDropTarget_DragOver,
2813 ISFDropTarget_DragLeave,