4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied
19 #include "wine/obj_base.h"
20 #include "wine/obj_dragdrop.h"
21 #include "wine/obj_shellfolder.h"
22 #include "shell32_main.h"
24 DEFAULT_DEBUG_CHANNEL(shell)
26 /***************************************************************************
27 * IDropTarget interface definition for the ShellFolder
31 { ICOM_VTABLE(IDropTarget)* lpvtbl;
35 static struct ICOM_VTABLE(IDropTarget) dtvt;
38 /****************************************************************************
39 * ISFDropTarget implementation
42 static IDropTarget * WINAPI ISFDropTarget_Constructor(void)
46 sf = HeapAlloc(GetProcessHeap(), 0, sizeof(ISFDropTarget));
53 return (IDropTarget *)sf;
56 static HRESULT WINAPI ISFDropTarget_QueryInterface(
61 ICOM_THIS(ISFDropTarget,iface);
64 WINE_StringFromCLSID((LPCLSID)riid,xriid);
66 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
68 if ( !This || !ppvObj)
73 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
76 else if(IsEqualIID(riid, &IID_IDropTarget)) /*IShellFolder*/
77 { *ppvObj = (ISFDropTarget*)This;
81 { IDropTarget_AddRef((IDropTarget*)*ppvObj);
82 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
86 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
91 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
93 ICOM_THIS(ISFDropTarget,iface);
95 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
102 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
104 ICOM_THIS(ISFDropTarget,iface);
109 { TRACE(shell,"-- destroying ISFDropTarget (%p)\n",This);
110 HeapFree(GetProcessHeap(),0,This);
116 static HRESULT WINAPI ISFDropTarget_DragEnter(
118 IDataObject *pDataObject,
124 ICOM_THIS(ISFDropTarget,iface);
126 FIXME(shell, "Stub: This=%p, DataObject=%p\n",This,pDataObject);
131 static HRESULT WINAPI ISFDropTarget_DragOver(
137 ICOM_THIS(ISFDropTarget,iface);
139 FIXME(shell, "Stub: This=%p\n",This);
144 static HRESULT WINAPI ISFDropTarget_DragLeave(
147 ICOM_THIS(ISFDropTarget,iface);
149 FIXME(shell, "Stub: This=%p\n",This);
154 static HRESULT WINAPI ISFDropTarget_Drop(
156 IDataObject* pDataObject,
161 ICOM_THIS(ISFDropTarget,iface);
163 FIXME(shell, "Stub: This=%p\n",This);
168 static struct ICOM_VTABLE(IDropTarget) dtvt =
170 ISFDropTarget_QueryInterface,
171 ISFDropTarget_AddRef,
172 ISFDropTarget_Release,
173 ISFDropTarget_DragEnter,
174 ISFDropTarget_DragOver,
175 ISFDropTarget_DragLeave,
179 /***************************************************************************
180 * GetNextElement (internal function)
182 * gets a part of a string till the first backslash
185 * pszNext [IN] string to get the element from
186 * pszOut [IN] pointer to buffer whitch receives string
187 * dwOut [IN] length of pszOut
190 * LPSTR pointer to first, not yet parsed char
192 LPSTR GetNextElement(LPSTR pszNext,LPSTR pszOut,DWORD dwOut)
193 { LPSTR pszTail = pszNext;
195 TRACE(shell,"(%s %p 0x%08lx)\n",debugstr_a(pszNext),pszOut,dwOut);
197 if(!pszNext || !*pszNext)
200 while(*pszTail && (*pszTail != '\\'))
203 dwCopy=((LPBYTE)pszTail-(LPBYTE)pszNext)/sizeof(CHAR)+1;
204 lstrcpynA(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
210 TRACE(shell,"--(%s %s 0x%08lx)\n",debugstr_a(pszNext),debugstr_a(pszOut),dwOut);
214 /***********************************************************************
215 * IShellFolder implementation
218 static struct ICOM_VTABLE(IShellFolder) sfvt;
219 static struct ICOM_VTABLE(IPersistFolder) psfvt;
221 #define _IPersistFolder_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder)))
222 #define _ICOM_THIS_From_IPersistFolder(class, name) class* This = (class*)(((void*)name)-_IPersistFolder_Offset);
224 /**************************************************************************
225 * IShellFolder_Constructor
228 IShellFolder * IShellFolder_Constructor(
229 IGenericSFImpl * pParent,
235 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IGenericSFImpl));
238 sf->lpvtblPersistFolder=&psfvt;
239 sf->sMyPath=NULL; /* path of the folder */
240 sf->pMyPidl=NULL; /* my qualified pidl */
242 TRACE(shell,"(%p)->(parent=%p, pidl=%p)\n",sf,pParent, pidl);
245 /* keep a copy of the pidl in the instance*/
246 sf->mpidl = ILClone(pidl); /* my short pidl */
248 if(sf->mpidl) /* do we have a pidl? */
250 if(pParent->sMyPath) /* get the size of the parents path */
251 { dwSize += strlen(pParent->sMyPath) ;
252 TRACE(shell,"-- (%p)->(parent's path=%s)\n",sf, debugstr_a(pParent->sMyPath));
254 dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
255 sf->sMyPath = SHAlloc(dwSize+2); /* '\0' and backslash */
259 if(pParent->sMyPath) /* if the parent has a path, get it*/
260 { strcpy(sf->sMyPath, pParent->sMyPath);
261 PathAddBackslashA (sf->sMyPath);
263 sf->pMyPidl = ILCombine(pParent->pMyPidl, pidl);
264 len = strlen(sf->sMyPath);
265 _ILGetFolderText(sf->mpidl, sf->sMyPath+len, dwSize-len);
266 TRACE(shell,"-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->pMyPidl,debugstr_a(sf->sMyPath));
271 return (IShellFolder *)sf;
273 /**************************************************************************
274 * IShellFolder_fnQueryInterface
277 * REFIID riid [in ] Requested InterfaceID
278 * LPVOID* ppvObject [out] Interface* to hold the result
280 static HRESULT WINAPI IShellFolder_fnQueryInterface(
281 IShellFolder * iface,
285 ICOM_THIS(IGenericSFImpl, iface);
288 WINE_StringFromCLSID((LPCLSID)riid,xriid);
289 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
293 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
296 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
297 { *ppvObj = (IShellFolder*)This;
299 else if(IsEqualIID(riid, &IID_IPersistFolder)) /*IPersistFolder*/
300 { *ppvObj = (IPersistFolder*)&(This->lpvtblPersistFolder);
304 { IShellFolder_AddRef((IShellFolder*)*ppvObj);
305 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
308 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
309 return E_NOINTERFACE;
312 /**************************************************************************
313 * IShellFolder::AddRef
316 static ULONG WINAPI IShellFolder_fnAddRef(IShellFolder * iface)
318 ICOM_THIS(IGenericSFImpl, iface);
320 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
323 return ++(This->ref);
326 /**************************************************************************
327 * IShellFolder_fnRelease
329 static ULONG WINAPI IShellFolder_fnRelease(IShellFolder * iface)
331 ICOM_THIS(IGenericSFImpl, iface);
333 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
337 { TRACE(shell,"-- destroying IShellFolder(%p)\n",This);
339 if (pdesktopfolder == iface)
340 { pdesktopfolder=NULL;
341 TRACE(shell,"-- destroyed IShellFolder(%p) was Desktopfolder\n",This);
344 { SHFree(This->pMyPidl);
347 { SHFree(This->mpidl);
350 { SHFree(This->sMyPath);
353 HeapFree(GetProcessHeap(),0,This);
359 /**************************************************************************
360 * IShellFolder_fnParseDisplayName
362 * HWND hwndOwner, //[in ] Parent window for any message's
363 * LPBC pbc, //[in ] reserved
364 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
365 * ULONG* pchEaten, //[out] (unicode) characters processed
366 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
367 * ULONG* pdwAttributes //[out] items attributes
370 * pdwAttributes: not used
372 static HRESULT WINAPI IShellFolder_fnParseDisplayName(
373 IShellFolder * iface,
376 LPOLESTR lpszDisplayName,
379 DWORD *pdwAttributes)
381 ICOM_THIS(IGenericSFImpl, iface);
383 HRESULT hr=E_OUTOFMEMORY;
384 LPITEMIDLIST pidlFull=NULL, pidlTemp = NULL, pidlOld = NULL;
386 CHAR szTemp[MAX_PATH],szElement[MAX_PATH];
389 TRACE(shell,"(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
390 This,hwndOwner,pbcReserved,lpszDisplayName,
391 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
394 WideCharToLocal(szTemp, lpszDisplayName, lstrlenW(lpszDisplayName) + 1);
396 { if (strcmp(szTemp,"Desktop")==0)
397 { pidlFull = _ILCreateDesktop();
399 else if (strcmp(szTemp,"My Computer")==0)
400 { pidlFull = _ILCreateMyComputer();
403 { if (!PathIsRootA(szTemp))
404 { if (This->sMyPath && strlen (This->sMyPath))
405 { if (strcmp(This->sMyPath,"My Computer"))
406 { strcpy (szElement,This->sMyPath);
407 PathAddBackslashA (szElement);
408 strcat (szElement, szTemp);
409 strcpy (szTemp, szElement);
414 /* check if the lpszDisplayName is Folder or File*/
415 bIsFile = ! (GetFileAttributesA(szTemp) & FILE_ATTRIBUTE_DIRECTORY);
416 pszNext = GetNextElement(szTemp, szElement, MAX_PATH);
418 pidlFull = _ILCreateMyComputer();
419 pidlTemp = _ILCreateDrive(szElement);
421 pidlFull = ILCombine(pidlFull,pidlTemp);
425 { while((pszNext=GetNextElement(pszNext, szElement, MAX_PATH)))
426 { if(!*pszNext && bIsFile)
427 { pidlTemp = _ILCreateValue(NULL, szElement); /* FIXME: shortname */
430 { pidlTemp = _ILCreateFolder(NULL, szElement); /* FIXME: shortname */
433 pidlFull = ILCombine(pidlFull,pidlTemp);
445 /**************************************************************************
446 * IShellFolder_fnEnumObjects
448 * HWND hwndOwner, //[in ] Parent Window
449 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
450 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
452 static HRESULT WINAPI IShellFolder_fnEnumObjects(
453 IShellFolder * iface,
456 LPENUMIDLIST* ppEnumIDList)
458 ICOM_THIS(IGenericSFImpl, iface);
460 TRACE(shell,"(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
462 *ppEnumIDList = NULL;
463 *ppEnumIDList = IEnumIDList_Constructor (This->sMyPath, dwFlags);
464 TRACE(shell,"-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
466 { return E_OUTOFMEMORY;
471 /**************************************************************************
472 * IShellFolder_fnBindToObject
474 * LPCITEMIDLIST pidl, //[in ] complex pidl to open
475 * LPBC pbc, //[in ] reserved
476 * REFIID riid, //[in ] Initial Interface
477 * LPVOID* ppvObject //[out] Interface*
479 static HRESULT WINAPI IShellFolder_fnBindToObject( IShellFolder * iface, LPCITEMIDLIST pidl,
480 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
482 ICOM_THIS(IGenericSFImpl, iface);
486 LPSHELLFOLDER pShellFolder;
488 WINE_StringFromCLSID(riid,xriid);
490 TRACE(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",This,pidl,pbcReserved,xriid,ppvOut);
494 pShellFolder = IShellFolder_Constructor(This, pidl);
497 return E_OUTOFMEMORY;
499 hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
500 pShellFolder->lpvtbl->fnRelease(pShellFolder);
501 TRACE(shell,"-- (%p)->(interface=%p)\n",This, ppvOut);
505 /**************************************************************************
506 * IShellFolder_fnBindToStorage
508 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
509 * LPBC pbc, //[in ] reserved
510 * REFIID riid, //[in ] Initial storage interface
511 * LPVOID* ppvObject //[out] Interface* returned
513 static HRESULT WINAPI IShellFolder_fnBindToStorage(
514 IShellFolder * iface,
520 ICOM_THIS(IGenericSFImpl, iface);
523 WINE_StringFromCLSID(riid,xriid);
525 FIXME(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",This,pidl,pbcReserved,xriid,ppvOut);
531 /**************************************************************************
532 * IShellFolder_fnCompareIDs
535 * LPARAM lParam, //[in ] Column?
536 * LPCITEMIDLIST pidl1, //[in ] simple pidl
537 * LPCITEMIDLIST pidl2) //[in ] simple pidl
540 * Special case - If one of the items is a Path and the other is a File,
541 * always make the Path come before the File.
544 * we have to handle simple pidl's only (?)
546 static HRESULT WINAPI IShellFolder_fnCompareIDs(
547 IShellFolder * iface,
552 ICOM_THIS(IGenericSFImpl, iface);
554 CHAR szString1[MAX_PATH] = "";
555 CHAR szString2[MAX_PATH] = "";
557 LPCITEMIDLIST pidlTemp1 = pidl1, pidlTemp2 = pidl2;
559 TRACE(shell,"(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",This,lParam,pidl1,pidl2);
563 if (!pidl1 && !pidl2)
565 if (!pidl1) /* Desktop < anything */
570 /* get the last item in each list */
571 pidlTemp1 = ILFindLastID(pidlTemp1);
572 pidlTemp2 = ILFindLastID(pidlTemp2);
574 /* at This point, both pidlTemp1 and pidlTemp2 point to the last item in the list */
575 if(_ILIsValue(pidlTemp1) != _ILIsValue(pidlTemp2))
576 { if(_ILIsValue(pidlTemp1))
581 _ILGetDrive( pidl1,szString1,sizeof(szString1));
582 _ILGetDrive( pidl2,szString2,sizeof(szString2));
583 nReturn = strcasecmp(szString1, szString2);
588 _ILGetFolderText( pidl1,szString1,sizeof(szString1));
589 _ILGetFolderText( pidl2,szString2,sizeof(szString2));
590 nReturn = strcasecmp(szString1, szString2);
595 _ILGetValueText(pidl1,szString1,sizeof(szString1));
596 _ILGetValueText(pidl2,szString2,sizeof(szString2));
597 return strcasecmp(szString1, szString2);
600 /**************************************************************************
601 * IShellFolder_fnCreateViewObject
602 * Creates an View Object representing the ShellFolder
603 * IShellView / IShellBrowser / IContextMenu
606 * HWND hwndOwner, // Handle of owner window
607 * REFIID riid, // Requested initial interface
608 * LPVOID* ppvObject) // Resultant interface*
611 * the same as SHCreateShellFolderViewEx ???
613 static HRESULT WINAPI IShellFolder_fnCreateViewObject( IShellFolder * iface,
614 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
616 ICOM_THIS(IGenericSFImpl, iface);
618 LPSHELLVIEW pShellView;
622 WINE_StringFromCLSID(riid,xriid);
623 TRACE(shell,"(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,xriid,ppvOut);
627 pShellView = IShellView_Constructor((IShellFolder *) This, This->mpidl);
630 return E_OUTOFMEMORY;
632 hr = pShellView->lpvtbl->fnQueryInterface(pShellView, riid, ppvOut);
633 pShellView->lpvtbl->fnRelease(pShellView);
634 TRACE(shell,"-- (%p)->(interface=%p)\n",This, ppvOut);
638 /**************************************************************************
639 * IShellFolder_fnGetAttributesOf
642 * UINT cidl, //[in ] num elements in pidl array
643 + LPCITEMIDLIST* apidl, //[in ] simple pidl array
644 * ULONG* rgfInOut) //[out] result array
647 * Note: rgfInOut is documented as being an array of ULONGS.
648 * This does not seem to be the case. Testing This function using the shell to
649 * call it with cidl > 1 (by deleting multiple items) reveals that the shell
650 * passes ONE element in the array and writing to further elements will
651 * cause the shell to fail later.
653 static HRESULT WINAPI IShellFolder_fnGetAttributesOf(IShellFolder * iface,UINT cidl,LPCITEMIDLIST *apidl,DWORD *rgfInOut)
655 ICOM_THIS(IGenericSFImpl, iface);
657 LPCITEMIDLIST * pidltemp;
660 TRACE(shell,"(%p)->(%d,%p,%p)\n",This,cidl,apidl,rgfInOut);
662 if ( (!cidl) || (!apidl) || (!rgfInOut))
669 TRACE(shell,"-- mask=0x%08lx\n",*rgfInOut);
674 if (_ILIsDesktop( *pidltemp))
675 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
677 else if (_ILIsMyComputer( *pidltemp))
678 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
679 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK );
681 else if (_ILIsDrive( *pidltemp))
682 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
683 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
685 else if (_ILIsFolder( *pidltemp))
686 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_CAPABILITYMASK );
688 else if (_ILIsValue( *pidltemp))
689 { *rgfInOut |= (SFGAO_FILESYSTEM | SFGAO_CAPABILITYMASK );
694 } while (cidl > 0 && *pidltemp);
698 /**************************************************************************
699 * IShellFolder_fnGetUIObjectOf
702 * HWND hwndOwner, //[in ] Parent window for any output
703 * UINT cidl, //[in ] array size
704 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
705 * REFIID riid, //[in ] Requested Interface
706 * UINT* prgfInOut, //[ ] reserved
707 * LPVOID* ppvObject) //[out] Resulting Interface
710 * This function gets asked to return "view objects" for one or more (multiple select)
712 * The viewobject typically is an COM object with one of the following interfaces:
713 * IExtractIcon,IDataObject,IContextMenu
714 * In order to support icon positions in the default Listview your DataObject
715 * must implement the SetData method (in addition to GetData :) - the shell passes
716 * a barely documented "Icon positions" structure to SetData when the drag starts,
717 * and GetData's it if the drop is in another explorer window that needs the positions.
719 static HRESULT WINAPI IShellFolder_fnGetUIObjectOf(
720 IShellFolder * iface,
723 LPCITEMIDLIST * apidl,
728 ICOM_THIS(IGenericSFImpl, iface);
732 LPUNKNOWN pObj = NULL;
734 WINE_StringFromCLSID(riid,xclsid);
736 TRACE(shell,"(%p)->(%u,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
737 This,hwndOwner,cidl,apidl,xclsid,prgfInOut,ppvOut);
741 if(IsEqualIID(riid, &IID_IContextMenu))
746 pObj = (LPUNKNOWN)IContextMenu_Constructor((IShellFolder *)This, apidl, cidl);
748 else if (IsEqualIID(riid, &IID_IDataObject))
751 return(E_INVALIDARG);
753 pObj = (LPUNKNOWN)IDataObject_Constructor (hwndOwner, (IShellFolder *)This, apidl, cidl);
755 else if(IsEqualIID(riid, &IID_IExtractIconA))
758 return(E_INVALIDARG);
760 pidl = ILCombine(This->pMyPidl,apidl[0]);
761 pObj = (LPUNKNOWN)IExtractIconA_Constructor( pidl );
764 else if (IsEqualIID(riid, &IID_IDropTarget))
767 return(E_INVALIDARG);
769 pObj = (LPUNKNOWN)ISFDropTarget_Constructor();
773 ERR(shell,"(%p)->E_NOINTERFACE\n",This);
774 return E_NOINTERFACE;
778 return E_OUTOFMEMORY;
783 /**************************************************************************
784 * IShellFolder_fnGetDisplayNameOf
785 * Retrieves the display name for the specified file object or subfolder
788 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
789 * DWORD dwFlags, //[in ] SHGNO formatting flags
790 * LPSTRRET lpName) //[out] Returned display name
793 * if the name is in the pidl the ret value should be a STRRET_OFFSET
795 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
796 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
798 static HRESULT WINAPI IShellFolder_fnGetDisplayNameOf(
799 IShellFolder * iface,
804 ICOM_THIS(IGenericSFImpl, iface);
806 CHAR szText[MAX_PATH];
807 CHAR szTemp[MAX_PATH];
808 CHAR szSpecial[MAX_PATH];
809 CHAR szDrive[MAX_PATH];
810 DWORD dwVolumeSerialNumber,dwMaximumComponetLength,dwFileSystemFlags;
811 LPITEMIDLIST pidlTemp=NULL;
812 BOOL bSimplePidl=FALSE;
814 TRACE(shell,"(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,lpName);
822 /* test if simple(relative) or complex(absolute) pidl */
823 pidlTemp = ILGetNext(pidl);
824 if (pidlTemp && pidlTemp->mkid.cb==0x00)
825 { bSimplePidl = TRUE;
826 TRACE(shell,"-- simple pidl\n");
829 if (_ILIsDesktop( pidl))
830 { strcpy (szText,"Desktop");
833 { if (_ILIsMyComputer(pidl))
834 { _ILGetItemText(pidl, szSpecial, MAX_PATH);
835 pidl = ILGetNext(pidl);
838 if (_ILIsDrive(pidl))
839 { _ILGetDrive( pidl, szTemp, MAX_PATH);
841 if ( dwFlags==SHGDN_NORMAL || dwFlags==SHGDN_INFOLDER) /* like "A1-dos (C:)" */
842 { GetVolumeInformationA(szTemp,szDrive,MAX_PATH,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
843 szTemp[2]=0x00; /* overwrite '\' */
844 strcat (szDrive," (");
845 strcat (szDrive,szTemp);
846 strcat (szDrive,")");
848 else /* like "C:\" */
849 { PathAddBackslashA (szTemp);
850 strcpy(szDrive,szTemp);
856 { case SHGDN_NORMAL: /* 0x0000 */
857 _ILGetPidlPath( pidl, szText, MAX_PATH);
860 case SHGDN_INFOLDER | SHGDN_FORPARSING: /* 0x8001 */
861 case SHGDN_INFOLDER: /* 0x0001 */
862 pidlTemp = ILFindLastID(pidl);
864 { _ILGetItemText( pidlTemp, szText, MAX_PATH);
868 case SHGDN_FORPARSING: /* 0x8000 */
870 { /* if the IShellFolder has parents, get the path from the
871 parent and add the ItemName*/
873 if (This->sMyPath && strlen (This->sMyPath))
874 { if (strcmp(This->sMyPath,"My Computer"))
875 { strcpy (szText,This->sMyPath);
876 PathAddBackslashA (szText);
879 pidlTemp = ILFindLastID(pidl);
881 { _ILGetItemText( pidlTemp, szTemp, MAX_PATH );
883 strcat(szText,szTemp);
885 else /* if the pidl is absolute, get everything from the pidl*/
886 { _ILGetPidlPath( pidl, szText, MAX_PATH);
890 TRACE(shell,"--- wrong flags=%lx\n", dwFlags);
893 if ((szText[0]==0x00 && szDrive[0]!=0x00)|| (bSimplePidl && szDrive[0]!=0x00))
894 { strcpy(szText,szDrive);
896 if (szText[0]==0x00 && szSpecial[0]!=0x00)
897 { strcpy(szText,szSpecial);
901 TRACE(shell,"-- (%p)->(%s)\n",This,szText);
904 { return E_OUTOFMEMORY;
906 lpName->uType = STRRET_CSTRA;
907 strcpy(lpName->u.cStr,szText);
911 /**************************************************************************
912 * IShellFolder_fnSetNameOf
913 * Changes the name of a file object or subfolder, possibly changing its item
914 * identifier in the process.
917 * HWND hwndOwner, //[in ] Owner window for output
918 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
919 * LPCOLESTR lpszName, //[in ] the items new display name
920 * DWORD dwFlags, //[in ] SHGNO formatting flags
921 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
923 static HRESULT WINAPI IShellFolder_fnSetNameOf(
924 IShellFolder * iface,
926 LPCITEMIDLIST pidl, /*simple pidl*/
929 LPITEMIDLIST *pPidlOut)
931 ICOM_THIS(IGenericSFImpl, iface);
933 FIXME(shell,"(%p)->(%u,pidl=%p,%s,%lu,%p),stub!\n",
934 This,hwndOwner,pidl,debugstr_w(lpName),dw,pPidlOut);
939 /**************************************************************************
940 * IShellFolder_fnGetFolderPath
941 * FIXME: drive not included
943 static HRESULT WINAPI IShellFolder_fnGetFolderPath(IShellFolder * iface, LPSTR lpszOut, DWORD dwOutSize)
945 ICOM_THIS(IGenericSFImpl, iface);
948 TRACE(shell,"(%p)->(%p %lu)\n",This, lpszOut, dwOutSize);
958 dwSize = strlen (This->sMyPath) +1;
959 if ( dwSize > dwOutSize)
961 strcpy(lpszOut, This->sMyPath);
963 TRACE(shell,"-- (%p)->(return=%s)\n",This, lpszOut);
967 static ICOM_VTABLE(IShellFolder) sfvt =
968 { IShellFolder_fnQueryInterface,
969 IShellFolder_fnAddRef,
970 IShellFolder_fnRelease,
971 IShellFolder_fnParseDisplayName,
972 IShellFolder_fnEnumObjects,
973 IShellFolder_fnBindToObject,
974 IShellFolder_fnBindToStorage,
975 IShellFolder_fnCompareIDs,
976 IShellFolder_fnCreateViewObject,
977 IShellFolder_fnGetAttributesOf,
978 IShellFolder_fnGetUIObjectOf,
979 IShellFolder_fnGetDisplayNameOf,
980 IShellFolder_fnSetNameOf,
981 IShellFolder_fnGetFolderPath
984 /************************************************************************
985 * ISFPersistFolder_QueryInterface (IUnknown)
987 * See Windows documentation for more details on IUnknown methods.
989 static HRESULT WINAPI ISFPersistFolder_QueryInterface(
990 IPersistFolder * iface,
994 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
996 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
999 /************************************************************************
1000 * ISFPersistFolder_AddRef (IUnknown)
1002 * See Windows documentation for more details on IUnknown methods.
1004 static ULONG WINAPI ISFPersistFolder_AddRef(
1005 IPersistFolder * iface)
1007 _ICOM_THIS_From_IPersistFolder(IShellFolder, iface);
1009 return IShellFolder_AddRef((IShellFolder*)This);
1012 /************************************************************************
1013 * ISFPersistFolder_Release (IUnknown)
1015 * See Windows documentation for more details on IUnknown methods.
1017 static ULONG WINAPI ISFPersistFolder_Release(
1018 IPersistFolder * iface)
1020 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1022 return IShellFolder_Release((IShellFolder*)This);
1025 /************************************************************************
1026 * ISFPersistFolder_GetClassID (IPersist)
1028 * See Windows documentation for more details on IPersist methods.
1030 static HRESULT WINAPI ISFPersistFolder_GetClassID(
1031 const IPersistFolder * iface,
1034 /* This ID is not documented anywhere but some tests in Windows tell
1035 * me that This is the ID for the "standard" implementation of the
1036 * IFolder interface.
1039 CLSID StdFolderID = { 0xF3364BA0, 0x65B9, 0x11CE, {0xA9, 0xBA, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37} };
1041 if (lpClassId==NULL)
1044 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
1049 /************************************************************************
1050 * ISFPersistFolder_Initialize (IPersistFolder)
1052 * See Windows documentation for more details on IPersistFolder methods.
1054 static HRESULT WINAPI ISFPersistFolder_Initialize(
1055 IPersistFolder * iface,
1058 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1061 { SHFree(This->pMyPidl);
1062 This->pMyPidl = NULL;
1064 This->pMyPidl = ILClone(pidl);
1068 static ICOM_VTABLE(IPersistFolder) psfvt =
1070 ISFPersistFolder_QueryInterface,
1071 ISFPersistFolder_AddRef,
1072 ISFPersistFolder_Release,
1073 ISFPersistFolder_GetClassID,
1074 ISFPersistFolder_Initialize