4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied
7 * IShellFolder with IDropTarget, IPersistFolder
14 #include "debugtools.h"
21 #include "wine/obj_base.h"
22 #include "wine/obj_dragdrop.h"
23 #include "wine/obj_shellfolder.h"
24 #include "shell32_main.h"
26 DEFAULT_DEBUG_CHANNEL(shell)
28 /***************************************************************************
29 * IDropTarget interface definition for the ShellFolder
33 { ICOM_VTABLE(IDropTarget)* lpvtbl;
37 static struct ICOM_VTABLE(IDropTarget) dtvt;
40 /****************************************************************************
41 * ISFDropTarget implementation
44 static IDropTarget * WINAPI ISFDropTarget_Constructor(void)
48 sf = HeapAlloc(GetProcessHeap(), 0, sizeof(ISFDropTarget));
55 return (IDropTarget *)sf;
58 static HRESULT WINAPI ISFDropTarget_QueryInterface(
63 ICOM_THIS(ISFDropTarget,iface);
66 WINE_StringFromCLSID((LPCLSID)riid,xriid);
68 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
70 if ( !This || !ppvObj)
75 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
78 else if(IsEqualIID(riid, &IID_IDropTarget)) /*IShellFolder*/
79 { *ppvObj = (ISFDropTarget*)This;
83 { IDropTarget_AddRef((IDropTarget*)*ppvObj);
84 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
88 TRACE("-- Interface: E_NOINTERFACE\n");
93 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
95 ICOM_THIS(ISFDropTarget,iface);
97 TRACE("(%p)->(count=%lu)\n",This,This->ref);
101 return ++(This->ref);
104 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
106 ICOM_THIS(ISFDropTarget,iface);
111 { TRACE("-- destroying ISFDropTarget (%p)\n",This);
112 HeapFree(GetProcessHeap(),0,This);
118 static HRESULT WINAPI ISFDropTarget_DragEnter(
120 IDataObject *pDataObject,
126 ICOM_THIS(ISFDropTarget,iface);
128 FIXME("Stub: This=%p, DataObject=%p\n",This,pDataObject);
133 static HRESULT WINAPI ISFDropTarget_DragOver(
139 ICOM_THIS(ISFDropTarget,iface);
141 FIXME("Stub: This=%p\n",This);
146 static HRESULT WINAPI ISFDropTarget_DragLeave(
149 ICOM_THIS(ISFDropTarget,iface);
151 FIXME("Stub: This=%p\n",This);
156 static HRESULT WINAPI ISFDropTarget_Drop(
158 IDataObject* pDataObject,
163 ICOM_THIS(ISFDropTarget,iface);
165 FIXME("Stub: This=%p\n",This);
170 static struct ICOM_VTABLE(IDropTarget) dtvt =
172 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
173 ISFDropTarget_QueryInterface,
174 ISFDropTarget_AddRef,
175 ISFDropTarget_Release,
176 ISFDropTarget_DragEnter,
177 ISFDropTarget_DragOver,
178 ISFDropTarget_DragLeave,
182 /***************************************************************************
183 * GetNextElement (internal function)
185 * gets a part of a string till the first backslash
188 * pszNext [IN] string to get the element from
189 * pszOut [IN] pointer to buffer whitch receives string
190 * dwOut [IN] length of pszOut
193 * LPSTR pointer to first, not yet parsed char
195 LPSTR GetNextElement(LPSTR pszNext,LPSTR pszOut,DWORD dwOut)
196 { LPSTR pszTail = pszNext;
198 TRACE("(%s %p 0x%08lx)\n",debugstr_a(pszNext),pszOut,dwOut);
200 if(!pszNext || !*pszNext)
203 while(*pszTail && (*pszTail != '\\'))
206 dwCopy=((LPBYTE)pszTail-(LPBYTE)pszNext)/sizeof(CHAR)+1;
207 lstrcpynA(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
213 TRACE("--(%s %s 0x%08lx)\n",debugstr_a(pszNext),debugstr_a(pszOut),dwOut);
217 /***********************************************************************
218 * IShellFolder implementation
221 static struct ICOM_VTABLE(IShellFolder) sfvt;
223 static struct ICOM_VTABLE(IPersistFolder) psfvt;
224 #define _IPersistFolder_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder)))
225 #define _ICOM_THIS_From_IPersistFolder(class, name) class* This = (class*)(((char*)name)-_IPersistFolder_Offset);
227 /**************************************************************************
228 * IShellFolder_Constructor
231 IShellFolder * IShellFolder_Constructor(
232 IGenericSFImpl * pParent,
238 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IGenericSFImpl));
242 sf->lpvtblPersistFolder=&psfvt;
244 sf->sMyPath=NULL; /* path of the folder */
245 sf->pMyPidl=NULL; /* my qualified pidl */
247 TRACE("(%p)->(parent=%p, pidl=%p)\n",sf,pParent, pidl);
250 /* keep a copy of the pidl in the instance*/
251 sf->mpidl = ILClone(pidl); /* my short pidl */
253 if(sf->mpidl) /* do we have a pidl? */
255 if(pParent->sMyPath) /* get the size of the parents path */
256 { dwSize += strlen(pParent->sMyPath) ;
257 TRACE("-- (%p)->(parent's path=%s)\n",sf, debugstr_a(pParent->sMyPath));
259 dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
260 sf->sMyPath = SHAlloc(dwSize+2); /* '\0' and backslash */
264 if(pParent->sMyPath) /* if the parent has a path, get it*/
265 { strcpy(sf->sMyPath, pParent->sMyPath);
266 PathAddBackslashA (sf->sMyPath);
268 sf->pMyPidl = ILCombine(pParent->pMyPidl, pidl);
269 len = strlen(sf->sMyPath);
270 _ILGetFolderText(sf->mpidl, sf->sMyPath+len, dwSize-len);
271 TRACE("-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->pMyPidl,debugstr_a(sf->sMyPath));
276 return (IShellFolder *)sf;
278 /**************************************************************************
279 * IShellFolder_fnQueryInterface
282 * REFIID riid [in ] Requested InterfaceID
283 * LPVOID* ppvObject [out] Interface* to hold the result
285 static HRESULT WINAPI IShellFolder_fnQueryInterface(
286 IShellFolder * iface,
290 ICOM_THIS(IGenericSFImpl, iface);
293 WINE_StringFromCLSID((LPCLSID)riid,xriid);
294 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
298 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
301 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
302 { *ppvObj = (IShellFolder*)This;
304 else if(IsEqualIID(riid, &IID_IPersistFolder)) /*IPersistFolder*/
305 { *ppvObj = (IPersistFolder*)&(This->lpvtblPersistFolder);
310 IUnknown_AddRef((IUnknown*)(*ppvObj));
311 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
314 TRACE("-- Interface: E_NOINTERFACE\n");
315 return E_NOINTERFACE;
318 /**************************************************************************
319 * IShellFolder::AddRef
322 static ULONG WINAPI IShellFolder_fnAddRef(IShellFolder * iface)
324 ICOM_THIS(IGenericSFImpl, iface);
326 TRACE("(%p)->(count=%lu)\n",This,This->ref);
329 return ++(This->ref);
332 /**************************************************************************
333 * IShellFolder_fnRelease
335 static ULONG WINAPI IShellFolder_fnRelease(IShellFolder * iface)
337 ICOM_THIS(IGenericSFImpl, iface);
339 TRACE("(%p)->(count=%lu)\n",This,This->ref);
343 { TRACE("-- destroying IShellFolder(%p)\n",This);
345 if (pdesktopfolder == iface)
346 { pdesktopfolder=NULL;
347 TRACE("-- destroyed IShellFolder(%p) was Desktopfolder\n",This);
350 { SHFree(This->pMyPidl);
353 { SHFree(This->mpidl);
356 { SHFree(This->sMyPath);
359 HeapFree(GetProcessHeap(),0,This);
365 /**************************************************************************
366 * IShellFolder_fnParseDisplayName
368 * HWND hwndOwner, //[in ] Parent window for any message's
369 * LPBC pbc, //[in ] reserved
370 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
371 * ULONG* pchEaten, //[out] (unicode) characters processed
372 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
373 * ULONG* pdwAttributes //[out] items attributes
376 * pdwAttributes: not used
378 static HRESULT WINAPI IShellFolder_fnParseDisplayName(
379 IShellFolder * iface,
382 LPOLESTR lpszDisplayName,
385 DWORD *pdwAttributes)
387 ICOM_THIS(IGenericSFImpl, iface);
389 HRESULT hr=E_OUTOFMEMORY;
390 LPITEMIDLIST pidlFull=NULL, pidlTemp = NULL, pidlOld = NULL, pidlNew = NULL;
392 CHAR szTemp[MAX_PATH],szElement[MAX_PATH];
395 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
396 This,hwndOwner,pbcReserved,lpszDisplayName,
397 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
400 WideCharToLocal(szTemp, lpszDisplayName, lstrlenW(lpszDisplayName) + 1);
403 { if (strcmp(szTemp,"Desktop")==0)
404 { pidlFull = _ILCreateDesktop();
406 else if (strcmp(szTemp,"My Computer")==0)
407 { pidlFull = _ILCreateMyComputer();
410 { if (!PathIsRootA(szTemp))
411 { if (This->sMyPath && strlen (This->sMyPath))
412 { if (strcmp(This->sMyPath,"My Computer"))
413 { strcpy (szElement,This->sMyPath);
414 PathAddBackslashA (szElement);
415 strcat (szElement, szTemp);
416 strcpy (szTemp, szElement);
420 /* check if the lpszDisplayName is Folder or File*/
421 bIsFile = ! (GetFileAttributesA(szTemp) & FILE_ATTRIBUTE_DIRECTORY);
422 pszNext = GetNextElement(szTemp, szElement, MAX_PATH);
424 pidlFull = _ILCreateMyComputer();
425 pidlTemp = _ILCreateDrive(szElement);
427 pidlFull = ILCombine(pidlFull,pidlTemp);
431 { while((pszNext=GetNextElement(pszNext, szElement, MAX_PATH)))
432 { if(!*pszNext && bIsFile)
433 { pidlTemp = _ILCreateValue(NULL, szElement); /* FIXME: shortname */
436 { pidlTemp = _ILCreateFolder(NULL, szElement); /* FIXME: shortname */
439 pidlFull = ILCombine(pidlFull,pidlTemp);
445 /* The following code is to make the absolute
446 pidl (pidlFull) relative to the current folder */
448 if((pidlNew = ILFindChild(This->pMyPidl,pidlFull)))
451 pidlFull = ILClone(pidlNew);
461 /**************************************************************************
462 * IShellFolder_fnEnumObjects
464 * HWND hwndOwner, //[in ] Parent Window
465 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
466 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
468 static HRESULT WINAPI IShellFolder_fnEnumObjects(
469 IShellFolder * iface,
472 LPENUMIDLIST* ppEnumIDList)
474 ICOM_THIS(IGenericSFImpl, iface);
476 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
478 *ppEnumIDList = NULL;
479 *ppEnumIDList = IEnumIDList_Constructor (This->sMyPath, dwFlags);
480 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
482 { return E_OUTOFMEMORY;
487 /**************************************************************************
488 * IShellFolder_fnBindToObject
490 * LPCITEMIDLIST pidl, //[in ] complex pidl to open
491 * LPBC pbc, //[in ] reserved
492 * REFIID riid, //[in ] Initial Interface
493 * LPVOID* ppvObject //[out] Interface*
495 static HRESULT WINAPI IShellFolder_fnBindToObject( IShellFolder * iface, LPCITEMIDLIST pidl,
496 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
498 ICOM_THIS(IGenericSFImpl, iface);
502 LPSHELLFOLDER pShellFolder;
504 WINE_StringFromCLSID(riid,xriid);
506 TRACE("(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",This,pidl,pbcReserved,xriid,ppvOut);
510 pShellFolder = IShellFolder_Constructor(This, pidl);
513 return E_OUTOFMEMORY;
515 hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
516 pShellFolder->lpvtbl->fnRelease(pShellFolder);
517 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
521 /**************************************************************************
522 * IShellFolder_fnBindToStorage
524 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
525 * LPBC pbc, //[in ] reserved
526 * REFIID riid, //[in ] Initial storage interface
527 * LPVOID* ppvObject //[out] Interface* returned
529 static HRESULT WINAPI IShellFolder_fnBindToStorage(
530 IShellFolder * iface,
536 ICOM_THIS(IGenericSFImpl, iface);
539 WINE_StringFromCLSID(riid,xriid);
541 FIXME("(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",This,pidl,pbcReserved,xriid,ppvOut);
547 /**************************************************************************
548 * IShellFolder_fnCompareIDs
551 * LPARAM lParam, //[in ] Column?
552 * LPCITEMIDLIST pidl1, //[in ] simple pidl
553 * LPCITEMIDLIST pidl2) //[in ] simple pidl
556 * Special case - If one of the items is a Path and the other is a File,
557 * always make the Path come before the File.
560 * we have to handle simple pidl's only (?)
562 static HRESULT WINAPI IShellFolder_fnCompareIDs(
563 IShellFolder * iface,
568 ICOM_THIS(IGenericSFImpl, iface);
570 CHAR szString1[MAX_PATH] = "";
571 CHAR szString2[MAX_PATH] = "";
573 LPCITEMIDLIST pidlTemp1 = pidl1, pidlTemp2 = pidl2;
575 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",This,lParam,pidl1,pidl2);
579 if (!pidl1 && !pidl2)
581 if (!pidl1) /* Desktop < anything */
586 /* get the last item in each list */
587 pidlTemp1 = ILFindLastID(pidlTemp1);
588 pidlTemp2 = ILFindLastID(pidlTemp2);
590 /* at This point, both pidlTemp1 and pidlTemp2 point to the last item in the list */
591 if(_ILIsValue(pidlTemp1) != _ILIsValue(pidlTemp2))
592 { if(_ILIsValue(pidlTemp1))
597 _ILGetDrive( pidl1,szString1,sizeof(szString1));
598 _ILGetDrive( pidl2,szString2,sizeof(szString2));
599 nReturn = strcasecmp(szString1, szString2);
604 _ILGetFolderText( pidl1,szString1,sizeof(szString1));
605 _ILGetFolderText( pidl2,szString2,sizeof(szString2));
606 nReturn = strcasecmp(szString1, szString2);
611 _ILGetValueText(pidl1,szString1,sizeof(szString1));
612 _ILGetValueText(pidl2,szString2,sizeof(szString2));
613 return strcasecmp(szString1, szString2);
616 /**************************************************************************
617 * IShellFolder_fnCreateViewObject
618 * Creates an View Object representing the ShellFolder
619 * IShellView / IShellBrowser / IContextMenu
622 * HWND hwndOwner, // Handle of owner window
623 * REFIID riid, // Requested initial interface
624 * LPVOID* ppvObject) // Resultant interface*
627 * the same as SHCreateShellFolderViewEx ???
629 static HRESULT WINAPI IShellFolder_fnCreateViewObject( IShellFolder * iface,
630 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
632 ICOM_THIS(IGenericSFImpl, iface);
634 LPSHELLVIEW pShellView;
638 WINE_StringFromCLSID(riid,xriid);
639 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,xriid,ppvOut);
643 pShellView = IShellView_Constructor((IShellFolder *) This, This->mpidl);
646 return E_OUTOFMEMORY;
648 hr = pShellView->lpvtbl->fnQueryInterface(pShellView, riid, ppvOut);
649 pShellView->lpvtbl->fnRelease(pShellView);
650 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
654 /**************************************************************************
655 * IShellFolder_fnGetAttributesOf
658 * UINT cidl, //[in ] num elements in pidl array
659 + LPCITEMIDLIST* apidl, //[in ] simple pidl array
660 * ULONG* rgfInOut) //[out] result array
663 * Note: rgfInOut is documented as being an array of ULONGS.
664 * This does not seem to be the case. Testing This function using the shell to
665 * call it with cidl > 1 (by deleting multiple items) reveals that the shell
666 * passes ONE element in the array and writing to further elements will
667 * cause the shell to fail later.
669 static HRESULT WINAPI IShellFolder_fnGetAttributesOf(IShellFolder * iface,UINT cidl,LPCITEMIDLIST *apidl,DWORD *rgfInOut)
671 ICOM_THIS(IGenericSFImpl, iface);
673 LPCITEMIDLIST * pidltemp;
676 TRACE("(%p)->(%d,%p,%p)\n",This,cidl,apidl,rgfInOut);
678 if ( (!cidl) || (!apidl) || (!rgfInOut))
685 TRACE("-- mask=0x%08lx\n",*rgfInOut);
690 if (_ILIsDesktop( *pidltemp))
691 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
693 else if (_ILIsMyComputer( *pidltemp))
694 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
695 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK );
697 else if (_ILIsDrive( *pidltemp))
698 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
699 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
701 else if (_ILIsFolder( *pidltemp))
702 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_CAPABILITYMASK );
704 else if (_ILIsValue( *pidltemp))
705 { *rgfInOut |= (SFGAO_FILESYSTEM | SFGAO_CAPABILITYMASK );
710 } while (cidl > 0 && *pidltemp);
714 /**************************************************************************
715 * IShellFolder_fnGetUIObjectOf
718 * HWND hwndOwner, //[in ] Parent window for any output
719 * UINT cidl, //[in ] array size
720 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
721 * REFIID riid, //[in ] Requested Interface
722 * UINT* prgfInOut, //[ ] reserved
723 * LPVOID* ppvObject) //[out] Resulting Interface
726 * This function gets asked to return "view objects" for one or more (multiple select)
728 * The viewobject typically is an COM object with one of the following interfaces:
729 * IExtractIcon,IDataObject,IContextMenu
730 * In order to support icon positions in the default Listview your DataObject
731 * must implement the SetData method (in addition to GetData :) - the shell passes
732 * a barely documented "Icon positions" structure to SetData when the drag starts,
733 * and GetData's it if the drop is in another explorer window that needs the positions.
735 static HRESULT WINAPI IShellFolder_fnGetUIObjectOf(
736 IShellFolder * iface,
739 LPCITEMIDLIST * apidl,
744 ICOM_THIS(IGenericSFImpl, iface);
748 LPUNKNOWN pObj = NULL;
750 WINE_StringFromCLSID(riid,xclsid);
752 TRACE("(%p)->(%u,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
753 This,hwndOwner,cidl,apidl,xclsid,prgfInOut,ppvOut);
757 if(IsEqualIID(riid, &IID_IContextMenu))
762 pObj = (LPUNKNOWN)IContextMenu_Constructor((IShellFolder *)This, apidl, cidl);
764 else if (IsEqualIID(riid, &IID_IDataObject))
767 return(E_INVALIDARG);
769 pObj = (LPUNKNOWN)IDataObject_Constructor (hwndOwner, (IShellFolder *)This, apidl, cidl);
771 else if(IsEqualIID(riid, &IID_IExtractIconA))
774 return(E_INVALIDARG);
776 pidl = ILCombine(This->pMyPidl,apidl[0]);
777 pObj = (LPUNKNOWN)IExtractIconA_Constructor( pidl );
780 else if (IsEqualIID(riid, &IID_IDropTarget))
783 return(E_INVALIDARG);
785 pObj = (LPUNKNOWN)ISFDropTarget_Constructor();
789 ERR("(%p)->E_NOINTERFACE\n",This);
790 return E_NOINTERFACE;
794 return E_OUTOFMEMORY;
799 /**************************************************************************
800 * IShellFolder_fnGetDisplayNameOf
801 * Retrieves the display name for the specified file object or subfolder
804 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
805 * DWORD dwFlags, //[in ] SHGNO formatting flags
806 * LPSTRRET lpName) //[out] Returned display name
809 * if the name is in the pidl the ret value should be a STRRET_OFFSET
811 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
812 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
814 static HRESULT WINAPI IShellFolder_fnGetDisplayNameOf(
815 IShellFolder * iface,
820 ICOM_THIS(IGenericSFImpl, iface);
822 CHAR szText[MAX_PATH];
823 CHAR szTemp[MAX_PATH];
824 CHAR szSpecial[MAX_PATH];
825 CHAR szDrive[MAX_PATH];
826 DWORD dwVolumeSerialNumber,dwMaximumComponetLength,dwFileSystemFlags;
827 LPITEMIDLIST pidlTemp=NULL;
828 BOOL bSimplePidl=FALSE;
830 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,lpName);
838 /* test if simple(relative) or complex(absolute) pidl */
839 pidlTemp = ILGetNext(pidl);
840 if (pidlTemp && !pidlTemp->mkid.cb )
841 { bSimplePidl = TRUE;
842 TRACE("-- simple pidl\n");
845 if (_ILIsDesktop( pidl))
846 { strcpy (szText,"Desktop");
849 { if (_ILIsMyComputer(pidl))
850 { _ILGetItemText(pidl, szSpecial, MAX_PATH);
851 pidl = ILGetNext(pidl);
854 if (_ILIsDrive(pidl))
855 { _ILGetDrive( pidl, szTemp, MAX_PATH);
857 if ( dwFlags==SHGDN_NORMAL || dwFlags==SHGDN_INFOLDER) /* like "A1-dos (C:)" */
858 { GetVolumeInformationA(szTemp,szDrive,MAX_PATH,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
859 szTemp[2]=0x00; /* overwrite '\' */
860 strcat (szDrive," (");
861 strcat (szDrive,szTemp);
862 strcat (szDrive,")");
864 else /* like "C:\" */
865 { PathAddBackslashA (szTemp);
866 strcpy(szDrive,szTemp);
872 { case SHGDN_NORMAL: /* 0x0000 */
873 _ILGetPidlPath( pidl, szText, MAX_PATH);
876 case SHGDN_INFOLDER | SHGDN_FORPARSING: /* 0x8001 */
877 case SHGDN_INFOLDER: /* 0x0001 */
878 pidlTemp = ILFindLastID(pidl);
880 { _ILGetItemText( pidlTemp, szText, MAX_PATH);
884 case SHGDN_FORPARSING: /* 0x8000 */
886 { /* if the IShellFolder has parents, get the path from the
887 parent and add the ItemName*/
889 if (This->sMyPath && strlen (This->sMyPath))
890 { if (strcmp(This->sMyPath,"My Computer"))
891 { strcpy (szText,This->sMyPath);
892 PathAddBackslashA (szText);
895 pidlTemp = ILFindLastID(pidl);
897 { _ILGetItemText( pidlTemp, szTemp, MAX_PATH );
899 strcat(szText,szTemp);
901 else /* if the pidl is absolute, get everything from the pidl*/
902 { _ILGetPidlPath( pidl, szText, MAX_PATH);
906 TRACE("--- wrong flags=%lx\n", dwFlags);
909 if ((szText[0]==0x00 && szDrive[0]!=0x00)|| (bSimplePidl && szDrive[0]!=0x00))
910 { strcpy(szText,szDrive);
912 if (szText[0]==0x00 && szSpecial[0]!=0x00)
913 { strcpy(szText,szSpecial);
917 TRACE("-- (%p)->(%s)\n",This,szText);
920 { return E_OUTOFMEMORY;
922 lpName->uType = STRRET_CSTRA;
923 strcpy(lpName->u.cStr,szText);
927 /**************************************************************************
928 * IShellFolder_fnSetNameOf
929 * Changes the name of a file object or subfolder, possibly changing its item
930 * identifier in the process.
933 * HWND hwndOwner, //[in ] Owner window for output
934 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
935 * LPCOLESTR lpszName, //[in ] the items new display name
936 * DWORD dwFlags, //[in ] SHGNO formatting flags
937 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
939 static HRESULT WINAPI IShellFolder_fnSetNameOf(
940 IShellFolder * iface,
942 LPCITEMIDLIST pidl, /*simple pidl*/
945 LPITEMIDLIST *pPidlOut)
947 ICOM_THIS(IGenericSFImpl, iface);
949 FIXME("(%p)->(%u,pidl=%p,%s,%lu,%p),stub!\n",
950 This,hwndOwner,pidl,debugstr_w(lpName),dw,pPidlOut);
955 /**************************************************************************
956 * IShellFolder_fnGetFolderPath
957 * FIXME: drive not included
959 static HRESULT WINAPI IShellFolder_fnGetFolderPath(IShellFolder * iface, LPSTR lpszOut, DWORD dwOutSize)
961 ICOM_THIS(IGenericSFImpl, iface);
964 TRACE("(%p)->(%p %lu)\n",This, lpszOut, dwOutSize);
974 dwSize = strlen (This->sMyPath) +1;
975 if ( dwSize > dwOutSize)
977 strcpy(lpszOut, This->sMyPath);
979 TRACE("-- (%p)->(return=%s)\n",This, lpszOut);
983 static ICOM_VTABLE(IShellFolder) sfvt =
985 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
986 IShellFolder_fnQueryInterface,
987 IShellFolder_fnAddRef,
988 IShellFolder_fnRelease,
989 IShellFolder_fnParseDisplayName,
990 IShellFolder_fnEnumObjects,
991 IShellFolder_fnBindToObject,
992 IShellFolder_fnBindToStorage,
993 IShellFolder_fnCompareIDs,
994 IShellFolder_fnCreateViewObject,
995 IShellFolder_fnGetAttributesOf,
996 IShellFolder_fnGetUIObjectOf,
997 IShellFolder_fnGetDisplayNameOf,
998 IShellFolder_fnSetNameOf,
999 IShellFolder_fnGetFolderPath
1002 /************************************************************************
1003 * ISFPersistFolder_QueryInterface (IUnknown)
1005 * See Windows documentation for more details on IUnknown methods.
1007 static HRESULT WINAPI ISFPersistFolder_QueryInterface(
1008 IPersistFolder * iface,
1012 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1014 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1017 /************************************************************************
1018 * ISFPersistFolder_AddRef (IUnknown)
1020 * See Windows documentation for more details on IUnknown methods.
1022 static ULONG WINAPI ISFPersistFolder_AddRef(
1023 IPersistFolder * iface)
1025 _ICOM_THIS_From_IPersistFolder(IShellFolder, iface);
1027 return IShellFolder_AddRef((IShellFolder*)This);
1030 /************************************************************************
1031 * ISFPersistFolder_Release (IUnknown)
1033 * See Windows documentation for more details on IUnknown methods.
1035 static ULONG WINAPI ISFPersistFolder_Release(
1036 IPersistFolder * iface)
1038 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1040 return IShellFolder_Release((IShellFolder*)This);
1043 /************************************************************************
1044 * ISFPersistFolder_GetClassID (IPersist)
1046 * See Windows documentation for more details on IPersist methods.
1048 static HRESULT WINAPI ISFPersistFolder_GetClassID(
1049 const IPersistFolder * iface,
1052 /* This ID is not documented anywhere but some tests in Windows tell
1053 * me that This is the ID for the "standard" implementation of the
1054 * IFolder interface.
1057 CLSID StdFolderID = { 0xF3364BA0, 0x65B9, 0x11CE, {0xA9, 0xBA, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37} };
1059 if (lpClassId==NULL)
1062 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
1067 /************************************************************************
1068 * ISFPersistFolder_Initialize (IPersistFolder)
1070 * See Windows documentation for more details on IPersistFolder methods.
1072 static HRESULT WINAPI ISFPersistFolder_Initialize(
1073 IPersistFolder * iface,
1076 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1079 { SHFree(This->pMyPidl);
1080 This->pMyPidl = NULL;
1082 This->pMyPidl = ILClone(pidl);
1086 static ICOM_VTABLE(IPersistFolder) psfvt =
1088 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1089 ISFPersistFolder_QueryInterface,
1090 ISFPersistFolder_AddRef,
1091 ISFPersistFolder_Release,
1092 ISFPersistFolder_GetClassID,
1093 ISFPersistFolder_Initialize