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 /***************************************************************************
25 * IDropTarget interface definition for the ShellFolder
29 { ICOM_VTABLE(IDropTarget)* lpvtbl;
33 static struct ICOM_VTABLE(IDropTarget) dtvt;
36 /****************************************************************************
37 * ISFDropTarget implementation
40 static IDropTarget * WINAPI ISFDropTarget_Constructor(void)
44 sf = HeapAlloc(GetProcessHeap(), 0, sizeof(ISFDropTarget));
51 return (IDropTarget *)sf;
54 static HRESULT WINAPI ISFDropTarget_QueryInterface(
59 ICOM_THIS(ISFDropTarget,iface);
62 WINE_StringFromCLSID((LPCLSID)riid,xriid);
64 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
66 if ( !This || !ppvObj)
71 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
74 else if(IsEqualIID(riid, &IID_IDropTarget)) /*IShellFolder*/
75 { *ppvObj = (ISFDropTarget*)This;
79 { IDropTarget_AddRef((IDropTarget*)*ppvObj);
80 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
84 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
89 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
91 ICOM_THIS(ISFDropTarget,iface);
93 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
100 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
102 ICOM_THIS(ISFDropTarget,iface);
107 { TRACE(shell,"-- destroying ISFDropTarget (%p)\n",This);
108 HeapFree(GetProcessHeap(),0,This);
114 static HRESULT WINAPI ISFDropTarget_DragEnter(
116 IDataObject *pDataObject,
122 ICOM_THIS(ISFDropTarget,iface);
124 FIXME(shell, "Stub: This=%p, DataObject=%p\n",This,pDataObject);
129 static HRESULT WINAPI ISFDropTarget_DragOver(
135 ICOM_THIS(ISFDropTarget,iface);
137 FIXME(shell, "Stub: This=%p\n",This);
142 static HRESULT WINAPI ISFDropTarget_DragLeave(
145 ICOM_THIS(ISFDropTarget,iface);
147 FIXME(shell, "Stub: This=%p\n",This);
152 static HRESULT WINAPI ISFDropTarget_Drop(
154 IDataObject* pDataObject,
159 ICOM_THIS(ISFDropTarget,iface);
161 FIXME(shell, "Stub: This=%p\n",This);
166 static struct ICOM_VTABLE(IDropTarget) dtvt =
168 ISFDropTarget_QueryInterface,
169 ISFDropTarget_AddRef,
170 ISFDropTarget_Release,
171 ISFDropTarget_DragEnter,
172 ISFDropTarget_DragOver,
173 ISFDropTarget_DragLeave,
177 /***************************************************************************
178 * GetNextElement (internal function)
180 * gets a part of a string till the first backslash
183 * pszNext [IN] string to get the element from
184 * pszOut [IN] pointer to buffer whitch receives string
185 * dwOut [IN] length of pszOut
188 * LPSTR pointer to first, not yet parsed char
190 LPSTR GetNextElement(LPSTR pszNext,LPSTR pszOut,DWORD dwOut)
191 { LPSTR pszTail = pszNext;
193 TRACE(shell,"(%s %p 0x%08lx)\n",debugstr_a(pszNext),pszOut,dwOut);
195 if(!pszNext || !*pszNext)
198 while(*pszTail && (*pszTail != '\\'))
201 dwCopy=((LPBYTE)pszTail-(LPBYTE)pszNext)/sizeof(CHAR)+1;
202 lstrcpynA(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
208 TRACE(shell,"--(%s %s 0x%08lx)\n",debugstr_a(pszNext),debugstr_a(pszOut),dwOut);
212 /***********************************************************************
213 * IShellFolder implementation
216 static struct ICOM_VTABLE(IShellFolder) sfvt;
217 static struct ICOM_VTABLE(IPersistFolder) psfvt;
219 #define _IPersistFolder_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder)))
220 #define _ICOM_THIS_From_IPersistFolder(class, name) class* This = (class*)(((void*)name)-_IPersistFolder_Offset);
222 /**************************************************************************
223 * IShellFolder_Constructor
226 IShellFolder * IShellFolder_Constructor(
227 IGenericSFImpl * pParent,
233 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IGenericSFImpl));
236 sf->lpvtblPersistFolder=&psfvt;
237 sf->sMyPath=NULL; /* path of the folder */
238 sf->pMyPidl=NULL; /* my qualified pidl */
240 TRACE(shell,"(%p)->(parent=%p, pidl=%p)\n",sf,pParent, pidl);
243 /* keep a copy of the pidl in the instance*/
244 sf->mpidl = ILClone(pidl); /* my short pidl */
246 if(sf->mpidl) /* do we have a pidl? */
248 if(pParent->sMyPath) /* get the size of the parents path */
249 { dwSize += strlen(pParent->sMyPath) ;
250 TRACE(shell,"-- (%p)->(parent's path=%s)\n",sf, debugstr_a(pParent->sMyPath));
252 dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
253 sf->sMyPath = SHAlloc(dwSize+2); /* '\0' and backslash */
257 if(pParent->sMyPath) /* if the parent has a path, get it*/
258 { strcpy(sf->sMyPath, pParent->sMyPath);
259 PathAddBackslashA (sf->sMyPath);
261 sf->pMyPidl = ILCombine(pParent->pMyPidl, pidl);
262 len = strlen(sf->sMyPath);
263 _ILGetFolderText(sf->mpidl, sf->sMyPath+len, dwSize-len);
264 TRACE(shell,"-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->pMyPidl,debugstr_a(sf->sMyPath));
269 return (IShellFolder *)sf;
271 /**************************************************************************
272 * IShellFolder_fnQueryInterface
275 * REFIID riid [in ] Requested InterfaceID
276 * LPVOID* ppvObject [out] Interface* to hold the result
278 static HRESULT WINAPI IShellFolder_fnQueryInterface(
279 IShellFolder * iface,
283 ICOM_THIS(IGenericSFImpl, iface);
286 WINE_StringFromCLSID((LPCLSID)riid,xriid);
287 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
291 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
294 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
295 { *ppvObj = (IShellFolder*)This;
297 else if(IsEqualIID(riid, &IID_IPersistFolder)) /*IPersistFolder*/
298 { *ppvObj = (IPersistFolder*)&(This->lpvtblPersistFolder);
302 { IShellFolder_AddRef((IShellFolder*)*ppvObj);
303 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
306 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
307 return E_NOINTERFACE;
310 /**************************************************************************
311 * IShellFolder::AddRef
314 static ULONG WINAPI IShellFolder_fnAddRef(IShellFolder * iface)
316 ICOM_THIS(IGenericSFImpl, iface);
318 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
321 return ++(This->ref);
324 /**************************************************************************
325 * IShellFolder_fnRelease
327 static ULONG WINAPI IShellFolder_fnRelease(IShellFolder * iface)
329 ICOM_THIS(IGenericSFImpl, iface);
331 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
335 { TRACE(shell,"-- destroying IShellFolder(%p)\n",This);
337 if (pdesktopfolder == iface)
338 { pdesktopfolder=NULL;
339 TRACE(shell,"-- destroyed IShellFolder(%p) was Desktopfolder\n",This);
342 { SHFree(This->pMyPidl);
345 { SHFree(This->mpidl);
348 { SHFree(This->sMyPath);
351 HeapFree(GetProcessHeap(),0,This);
357 /**************************************************************************
358 * IShellFolder_fnParseDisplayName
360 * HWND hwndOwner, //[in ] Parent window for any message's
361 * LPBC pbc, //[in ] reserved
362 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
363 * ULONG* pchEaten, //[out] (unicode) characters processed
364 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
365 * ULONG* pdwAttributes //[out] items attributes
368 * pdwAttributes: not used
370 static HRESULT WINAPI IShellFolder_fnParseDisplayName(
371 IShellFolder * iface,
374 LPOLESTR lpszDisplayName,
377 DWORD *pdwAttributes)
379 ICOM_THIS(IGenericSFImpl, iface);
381 HRESULT hr=E_OUTOFMEMORY;
382 LPITEMIDLIST pidlFull=NULL, pidlTemp = NULL, pidlOld = NULL;
384 CHAR szTemp[MAX_PATH],szElement[MAX_PATH];
387 TRACE(shell,"(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
388 This,hwndOwner,pbcReserved,lpszDisplayName,
389 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
392 WideCharToLocal(szTemp, lpszDisplayName, lstrlenW(lpszDisplayName) + 1);
394 { if (strcmp(szTemp,"Desktop")==0)
395 { pidlFull = _ILCreateDesktop();
397 else if (strcmp(szTemp,"My Computer")==0)
398 { pidlFull = _ILCreateMyComputer();
401 { if (!PathIsRootA(szTemp))
402 { if (This->sMyPath && strlen (This->sMyPath))
403 { if (strcmp(This->sMyPath,"My Computer"))
404 { strcpy (szElement,This->sMyPath);
405 PathAddBackslashA (szElement);
406 strcat (szElement, szTemp);
407 strcpy (szTemp, szElement);
412 /* check if the lpszDisplayName is Folder or File*/
413 bIsFile = ! (GetFileAttributesA(szTemp) & FILE_ATTRIBUTE_DIRECTORY);
414 pszNext = GetNextElement(szTemp, szElement, MAX_PATH);
416 pidlFull = _ILCreateMyComputer();
417 pidlTemp = _ILCreateDrive(szElement);
419 pidlFull = ILCombine(pidlFull,pidlTemp);
423 { while((pszNext=GetNextElement(pszNext, szElement, MAX_PATH)))
424 { if(!*pszNext && bIsFile)
425 { pidlTemp = _ILCreateValue(NULL, szElement); /* FIXME: shortname */
428 { pidlTemp = _ILCreateFolder(NULL, szElement); /* FIXME: shortname */
431 pidlFull = ILCombine(pidlFull,pidlTemp);
443 /**************************************************************************
444 * IShellFolder_fnEnumObjects
446 * HWND hwndOwner, //[in ] Parent Window
447 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
448 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
450 static HRESULT WINAPI IShellFolder_fnEnumObjects(
451 IShellFolder * iface,
454 LPENUMIDLIST* ppEnumIDList)
456 ICOM_THIS(IGenericSFImpl, iface);
458 TRACE(shell,"(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
460 *ppEnumIDList = NULL;
461 *ppEnumIDList = IEnumIDList_Constructor (This->sMyPath, dwFlags);
462 TRACE(shell,"-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
464 { return E_OUTOFMEMORY;
469 /**************************************************************************
470 * IShellFolder_fnBindToObject
472 * LPCITEMIDLIST pidl, //[in ] complex pidl to open
473 * LPBC pbc, //[in ] reserved
474 * REFIID riid, //[in ] Initial Interface
475 * LPVOID* ppvObject //[out] Interface*
477 static HRESULT WINAPI IShellFolder_fnBindToObject( IShellFolder * iface, LPCITEMIDLIST pidl,
478 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
480 ICOM_THIS(IGenericSFImpl, iface);
484 LPSHELLFOLDER pShellFolder;
486 WINE_StringFromCLSID(riid,xriid);
488 TRACE(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",This,pidl,pbcReserved,xriid,ppvOut);
492 pShellFolder = IShellFolder_Constructor(This, pidl);
495 return E_OUTOFMEMORY;
497 hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
498 pShellFolder->lpvtbl->fnRelease(pShellFolder);
499 TRACE(shell,"-- (%p)->(interface=%p)\n",This, ppvOut);
503 /**************************************************************************
504 * IShellFolder_fnBindToStorage
506 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
507 * LPBC pbc, //[in ] reserved
508 * REFIID riid, //[in ] Initial storage interface
509 * LPVOID* ppvObject //[out] Interface* returned
511 static HRESULT WINAPI IShellFolder_fnBindToStorage(
512 IShellFolder * iface,
518 ICOM_THIS(IGenericSFImpl, iface);
521 WINE_StringFromCLSID(riid,xriid);
523 FIXME(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",This,pidl,pbcReserved,xriid,ppvOut);
529 /**************************************************************************
530 * IShellFolder_fnCompareIDs
533 * LPARAM lParam, //[in ] Column?
534 * LPCITEMIDLIST pidl1, //[in ] simple pidl
535 * LPCITEMIDLIST pidl2) //[in ] simple pidl
538 * Special case - If one of the items is a Path and the other is a File,
539 * always make the Path come before the File.
542 * we have to handle simple pidl's only (?)
544 static HRESULT WINAPI IShellFolder_fnCompareIDs(
545 IShellFolder * iface,
550 ICOM_THIS(IGenericSFImpl, iface);
552 CHAR szString1[MAX_PATH] = "";
553 CHAR szString2[MAX_PATH] = "";
555 LPCITEMIDLIST pidlTemp1 = pidl1, pidlTemp2 = pidl2;
557 TRACE(shell,"(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",This,lParam,pidl1,pidl2);
561 if (!pidl1 && !pidl2)
563 if (!pidl1) /* Desktop < anything */
568 /* get the last item in each list */
569 while((ILGetNext(pidlTemp1))->mkid.cb)
570 pidlTemp1 = ILGetNext(pidlTemp1);
571 while((ILGetNext(pidlTemp2))->mkid.cb)
572 pidlTemp2 = ILGetNext(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(szString2, szString1);
588 _ILGetFolderText( pidl1,szString1,sizeof(szString1));
589 _ILGetFolderText( pidl2,szString2,sizeof(szString2));
590 nReturn = strcasecmp(szString2, szString1);
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_IExtractIcon))
758 return(E_INVALIDARG);
760 pidl = ILCombine(This->pMyPidl,apidl[0]);
761 pObj = (LPUNKNOWN)IExtractIcon_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