4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied
15 #include "wine/obj_base.h"
16 #include "wine/obj_dragdrop.h"
21 #include "shell32_main.h"
23 static HRESULT WINAPI IShellFolder_QueryInterface(LPSHELLFOLDER,REFIID,LPVOID*);
24 static ULONG WINAPI IShellFolder_AddRef(LPSHELLFOLDER);
25 static ULONG WINAPI IShellFolder_Release(LPSHELLFOLDER);
26 static HRESULT WINAPI IShellFolder_Initialize(LPSHELLFOLDER,LPCITEMIDLIST);
27 static HRESULT WINAPI IShellFolder_ParseDisplayName(LPSHELLFOLDER,HWND,LPBC,LPOLESTR,DWORD*,LPITEMIDLIST*,DWORD*);
28 static HRESULT WINAPI IShellFolder_EnumObjects(LPSHELLFOLDER,HWND,DWORD,LPENUMIDLIST*);
29 static HRESULT WINAPI IShellFolder_BindToObject(LPSHELLFOLDER,LPCITEMIDLIST,LPBC,REFIID,LPVOID*);
30 static HRESULT WINAPI IShellFolder_BindToStorage(LPSHELLFOLDER,LPCITEMIDLIST,LPBC,REFIID,LPVOID*);
31 static HRESULT WINAPI IShellFolder_CompareIDs(LPSHELLFOLDER,LPARAM,LPCITEMIDLIST,LPCITEMIDLIST);
32 static HRESULT WINAPI IShellFolder_CreateViewObject(LPSHELLFOLDER,HWND,REFIID,LPVOID*);
33 static HRESULT WINAPI IShellFolder_GetAttributesOf(LPSHELLFOLDER,UINT,LPCITEMIDLIST*,DWORD*);
34 static HRESULT WINAPI IShellFolder_GetUIObjectOf(LPSHELLFOLDER,HWND,UINT,LPCITEMIDLIST*,REFIID,UINT*,LPVOID*);
35 static HRESULT WINAPI IShellFolder_GetDisplayNameOf(LPSHELLFOLDER,LPCITEMIDLIST,DWORD,LPSTRRET);
36 static HRESULT WINAPI IShellFolder_SetNameOf(LPSHELLFOLDER,HWND,LPCITEMIDLIST,LPCOLESTR,DWORD,LPITEMIDLIST*);
37 static BOOL WINAPI IShellFolder_GetFolderPath(LPSHELLFOLDER,LPSTR,DWORD);
39 /***************************************************************************
40 * IDropTarget interface definition for the ShellFolder
44 { ICOM_VTABLE(IDropTarget)* lpvtbl;
48 static struct ICOM_VTABLE(IDropTarget) dtvt;
51 /****************************************************************************
52 * ISFDropTarget implementation
55 static IDropTarget * WINAPI ISFDropTarget_Constructor(void)
59 sf = HeapAlloc(GetProcessHeap(), 0, sizeof(ISFDropTarget));
66 return (IDropTarget *)sf;
69 static HRESULT WINAPI ISFDropTarget_QueryInterface(
74 ICOM_THIS(ISFDropTarget,iface);
77 WINE_StringFromCLSID((LPCLSID)riid,xriid);
79 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
81 if ( !This || !ppvObj)
86 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
89 else if(IsEqualIID(riid, &IID_IDropTarget)) /*IShellFolder*/
90 { *ppvObj = (ISFDropTarget*)This;
94 { IDropTarget_AddRef((ISFDropTarget*)*ppvObj);
95 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
99 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
101 return E_NOINTERFACE;
104 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
106 ICOM_THIS(ISFDropTarget,iface);
108 TRACE(shell,"(%p)->(count=%lu)\n",This,This->ref);
112 return ++(This->ref);
115 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
117 ICOM_THIS(ISFDropTarget,iface);
122 { TRACE(shell,"-- destroying ISFDropTarget (%p)\n",This);
123 HeapFree(GetProcessHeap(),0,This);
129 static HRESULT WINAPI ISFDropTarget_DragEnter(
131 IDataObject *pDataObject,
137 ICOM_THIS(ISFDropTarget,iface);
139 FIXME(shell, "Stub: This=%p, DataObject=%p\n",This,pDataObject);
144 static HRESULT WINAPI ISFDropTarget_DragOver(
150 ICOM_THIS(ISFDropTarget,iface);
152 FIXME(shell, "Stub: This=%p\n",This);
157 static HRESULT WINAPI ISFDropTarget_DragLeave(
160 ICOM_THIS(ISFDropTarget,iface);
162 FIXME(shell, "Stub: This=%p\n",This);
167 static HRESULT WINAPI ISFDropTarget_Drop(
169 IDataObject* pDataObject,
174 ICOM_THIS(ISFDropTarget,iface);
176 FIXME(shell, "Stub: This=%p\n",This);
181 static struct ICOM_VTABLE(IDropTarget) dtvt =
183 ISFDropTarget_QueryInterface,
184 ISFDropTarget_AddRef,
185 ISFDropTarget_Release,
186 ISFDropTarget_DragEnter,
187 ISFDropTarget_DragOver,
188 ISFDropTarget_DragLeave,
192 /***************************************************************************
193 * GetNextElement (internal function)
195 * gets a part of a string till the first backslash
198 * pszNext [IN] string to get the element from
199 * pszOut [IN] pointer to buffer whitch receives string
200 * dwOut [IN] length of pszOut
203 * LPSTR pointer to first, not yet parsed char
205 LPSTR GetNextElement(LPSTR pszNext,LPSTR pszOut,DWORD dwOut)
206 { LPSTR pszTail = pszNext;
208 TRACE(shell,"(%s %p 0x%08lx)\n",debugstr_a(pszNext),pszOut,dwOut);
210 if(!pszNext || !*pszNext)
213 while(*pszTail && (*pszTail != '\\'))
216 dwCopy=((LPBYTE)pszTail-(LPBYTE)pszNext)/sizeof(CHAR)+1;
217 lstrcpynA(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
223 TRACE(shell,"--(%s %s 0x%08lx)\n",debugstr_a(pszNext),debugstr_a(pszOut),dwOut);
227 /***********************************************************************
228 * IShellFolder implementation
230 static struct IShellFolder_VTable sfvt =
231 { IShellFolder_QueryInterface,
233 IShellFolder_Release,
234 IShellFolder_ParseDisplayName,
235 IShellFolder_EnumObjects,
236 IShellFolder_BindToObject,
237 IShellFolder_BindToStorage,
238 IShellFolder_CompareIDs,
239 IShellFolder_CreateViewObject,
240 IShellFolder_GetAttributesOf,
241 IShellFolder_GetUIObjectOf,
242 IShellFolder_GetDisplayNameOf,
243 IShellFolder_SetNameOf,
244 IShellFolder_GetFolderPath
246 /**************************************************************************
247 * IShellFolder_Constructor
250 LPSHELLFOLDER IShellFolder_Constructor(LPSHELLFOLDER pParent,LPITEMIDLIST pidl)
253 sf=(LPSHELLFOLDER)HeapAlloc(GetProcessHeap(),0,sizeof(IShellFolder));
256 sf->sMyPath=NULL; /* path of the folder */
257 sf->pMyPidl=NULL; /* my qualified pidl */
259 TRACE(shell,"(%p)->(parent=%p, pidl=%p)\n",sf,pParent, pidl);
262 /* keep a copy of the pidl in the instance*/
263 sf->mpidl = ILClone(pidl); /* my short pidl */
265 if(sf->mpidl) /* do we have a pidl? */
267 if(pParent->sMyPath) /* get the size of the parents path */
268 { dwSize += strlen(pParent->sMyPath) ;
269 TRACE(shell,"-- (%p)->(parent's path=%s)\n",sf, debugstr_a(pParent->sMyPath));
271 dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
272 sf->sMyPath = SHAlloc(dwSize+2); /* '\0' and backslash */
276 if(pParent->sMyPath) /* if the parent has a path, get it*/
277 { strcpy(sf->sMyPath, pParent->sMyPath);
278 PathAddBackslashA (sf->sMyPath);
280 sf->pMyPidl = ILCombine(pParent->pMyPidl, pidl);
281 len = strlen(sf->sMyPath);
282 _ILGetFolderText(sf->mpidl, sf->sMyPath+len, dwSize-len);
283 TRACE(shell,"-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->pMyPidl,debugstr_a(sf->sMyPath));
290 /**************************************************************************
291 * IShellFolder::QueryInterface
293 * REFIID riid, //[in ] Requested InterfaceID
294 * LPVOID* ppvObject) //[out] Interface* to hold the result
296 static HRESULT WINAPI IShellFolder_QueryInterface(
297 LPSHELLFOLDER this, REFIID riid, LPVOID *ppvObj)
299 WINE_StringFromCLSID((LPCLSID)riid,xriid);
300 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
304 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
307 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
308 { *ppvObj = (IShellFolder*)this;
312 { (*(LPSHELLFOLDER*)ppvObj)->lpvtbl->fnAddRef(this);
313 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
316 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
317 return E_NOINTERFACE;
320 /**************************************************************************
321 * IShellFolder::AddRef
324 static ULONG WINAPI IShellFolder_AddRef(LPSHELLFOLDER this)
325 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
327 return ++(this->ref);
330 /**************************************************************************
331 * IShellFolder_Release
333 static ULONG WINAPI IShellFolder_Release(LPSHELLFOLDER this)
334 { TRACE(shell,"(%p)->(count=%lu)\n",this,this->ref);
338 { TRACE(shell,"-- destroying IShellFolder(%p)\n",this);
340 if (pdesktopfolder==this)
341 { pdesktopfolder=NULL;
342 TRACE(shell,"-- destroyed IShellFolder(%p) was Desktopfolder\n",this);
345 { SHFree(this->pMyPidl);
348 { SHFree(this->mpidl);
351 { SHFree(this->sMyPath);
354 HeapFree(GetProcessHeap(),0,this);
360 /**************************************************************************
361 * IShellFolder_ParseDisplayName
363 * HWND hwndOwner, //[in ] Parent window for any message's
364 * LPBC pbc, //[in ] reserved
365 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
366 * ULONG* pchEaten, //[out] (unicode) characters processed
367 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
368 * ULONG* pdwAttributes //[out] items attributes
371 * pdwAttributes: not used
373 static HRESULT WINAPI IShellFolder_ParseDisplayName(
377 LPOLESTR lpszDisplayName,
380 DWORD *pdwAttributes)
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_EnumObjects
446 * HWND hwndOwner, //[in ] Parent Window
447 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
448 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
450 static HRESULT WINAPI IShellFolder_EnumObjects(
454 LPENUMIDLIST* ppEnumIDList)
455 { TRACE(shell,"(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",this,hwndOwner,dwFlags,ppEnumIDList);
457 *ppEnumIDList = NULL;
458 *ppEnumIDList = IEnumIDList_Constructor (this->sMyPath, dwFlags);
459 TRACE(shell,"-- (%p)->(new ID List: %p)\n",this,*ppEnumIDList);
461 { return E_OUTOFMEMORY;
465 /**************************************************************************
466 * IShellFolder_Initialize()
467 * IPersistFolder Method
469 static HRESULT WINAPI IShellFolder_Initialize( LPSHELLFOLDER this,LPCITEMIDLIST pidl)
470 { TRACE(shell,"(%p)->(pidl=%p)\n",this,pidl);
473 { SHFree(this->pMyPidl);
474 this->pMyPidl = NULL;
476 this->pMyPidl = ILClone(pidl);
480 /**************************************************************************
481 * IShellFolder_BindToObject
483 * LPCITEMIDLIST pidl, //[in ] complex pidl to open
484 * LPBC pbc, //[in ] reserved
485 * REFIID riid, //[in ] Initial Interface
486 * LPVOID* ppvObject //[out] Interface*
488 static HRESULT WINAPI IShellFolder_BindToObject( LPSHELLFOLDER this, LPCITEMIDLIST pidl,
489 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
492 LPSHELLFOLDER pShellFolder;
494 WINE_StringFromCLSID(riid,xriid);
496 TRACE(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",this,pidl,pbcReserved,xriid,ppvOut);
500 pShellFolder = IShellFolder_Constructor(this, pidl);
503 return E_OUTOFMEMORY;
505 hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
506 pShellFolder->lpvtbl->fnRelease(pShellFolder);
507 TRACE(shell,"-- (%p)->(interface=%p)\n",this, ppvOut);
511 /**************************************************************************
512 * IShellFolder_BindToStorage
514 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
515 * LPBC pbc, //[in ] reserved
516 * REFIID riid, //[in ] Initial storage interface
517 * LPVOID* ppvObject //[out] Interface* returned
519 static HRESULT WINAPI IShellFolder_BindToStorage(LPSHELLFOLDER this,
520 LPCITEMIDLIST pidl,LPBC pbcReserved, REFIID riid, LPVOID *ppvOut)
522 WINE_StringFromCLSID(riid,xriid);
524 FIXME(shell,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",this,pidl,pbcReserved,xriid,ppvOut);
530 /**************************************************************************
531 * IShellFolder_CompareIDs
534 * LPARAM lParam, //[in ] Column?
535 * LPCITEMIDLIST pidl1, //[in ] simple pidl
536 * LPCITEMIDLIST pidl2) //[in ] simple pidl
539 * Special case - If one of the items is a Path and the other is a File,
540 * always make the Path come before the File.
543 * we have to handle simple pidl's only (?)
545 static HRESULT WINAPI IShellFolder_CompareIDs(LPSHELLFOLDER this,
546 LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
547 { CHAR szString1[MAX_PATH] = "";
548 CHAR szString2[MAX_PATH] = "";
550 LPCITEMIDLIST pidlTemp1 = pidl1, pidlTemp2 = pidl2;
552 TRACE(shell,"(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",this,lParam,pidl1,pidl2);
556 if (!pidl1 && !pidl2)
558 if (!pidl1) /* Desktop < anything */
563 /* get the last item in each list */
564 while((ILGetNext(pidlTemp1))->mkid.cb)
565 pidlTemp1 = ILGetNext(pidlTemp1);
566 while((ILGetNext(pidlTemp2))->mkid.cb)
567 pidlTemp2 = ILGetNext(pidlTemp2);
569 /* at this point, both pidlTemp1 and pidlTemp2 point to the last item in the list */
570 if(_ILIsValue(pidlTemp1) != _ILIsValue(pidlTemp2))
571 { if(_ILIsValue(pidlTemp1))
576 _ILGetDrive( pidl1,szString1,sizeof(szString1));
577 _ILGetDrive( pidl2,szString1,sizeof(szString2));
578 nReturn = strcasecmp(szString1, szString2);
583 _ILGetFolderText( pidl1,szString1,sizeof(szString1));
584 _ILGetFolderText( pidl2,szString2,sizeof(szString2));
585 nReturn = strcasecmp(szString1, szString2);
590 _ILGetValueText(pidl1,szString1,sizeof(szString1));
591 _ILGetValueText(pidl2,szString2,sizeof(szString2));
592 return strcasecmp(szString1, szString2);
595 /**************************************************************************
596 * IShellFolder_CreateViewObject
597 * Creates an View Object representing the ShellFolder
598 * IShellView / IShellBrowser / IContextMenu
601 * HWND hwndOwner, // Handle of owner window
602 * REFIID riid, // Requested initial interface
603 * LPVOID* ppvObject) // Resultant interface*
606 * the same as SHCreateShellFolderViewEx ???
608 static HRESULT WINAPI IShellFolder_CreateViewObject( LPSHELLFOLDER this,
609 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
610 { LPSHELLVIEW pShellView;
614 WINE_StringFromCLSID(riid,xriid);
615 TRACE(shell,"(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",this,hwndOwner,xriid,ppvOut);
619 pShellView = IShellView_Constructor(this, this->mpidl);
622 return E_OUTOFMEMORY;
624 hr = pShellView->lpvtbl->fnQueryInterface(pShellView, riid, ppvOut);
625 pShellView->lpvtbl->fnRelease(pShellView);
626 TRACE(shell,"-- (%p)->(interface=%p)\n",this, ppvOut);
630 /**************************************************************************
631 * IShellFolder_GetAttributesOf
634 * UINT cidl, //[in ] num elements in pidl array
635 + LPCITEMIDLIST* apidl, //[in ] simple pidl array
636 * ULONG* rgfInOut) //[out] result array
639 * Note: rgfInOut is documented as being an array of ULONGS.
640 * This does not seem to be the case. Testing this function using the shell to
641 * call it with cidl > 1 (by deleting multiple items) reveals that the shell
642 * passes ONE element in the array and writing to further elements will
643 * cause the shell to fail later.
645 static HRESULT WINAPI IShellFolder_GetAttributesOf(LPSHELLFOLDER this,UINT cidl,LPCITEMIDLIST *apidl,DWORD *rgfInOut)
646 { LPCITEMIDLIST * pidltemp;
649 TRACE(shell,"(%p)->(%d,%p,%p)\n",this,cidl,apidl,rgfInOut);
651 if ((! cidl )| (!apidl) | (!rgfInOut))
658 TRACE(shell,"-- mask=0x%08lx\n",*rgfInOut);
663 if (_ILIsDesktop( *pidltemp))
664 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
666 else if (_ILIsMyComputer( *pidltemp))
667 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR
668 | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK );
670 else if (_ILIsDrive( *pidltemp))
671 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
672 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
674 else if (_ILIsFolder( *pidltemp))
675 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_CAPABILITYMASK );
677 else if (_ILIsValue( *pidltemp))
678 { *rgfInOut |= (SFGAO_FILESYSTEM | SFGAO_CAPABILITYMASK );
683 } while (cidl > 0 && *pidltemp);
687 /**************************************************************************
688 * IShellFolder_GetUIObjectOf
691 * HWND hwndOwner, //[in ] Parent window for any output
692 * UINT cidl, //[in ] array size
693 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
694 * REFIID riid, //[in ] Requested Interface
695 * UINT* prgfInOut, //[ ] reserved
696 * LPVOID* ppvObject) //[out] Resulting Interface
699 * This function gets asked to return "view objects" for one or more (multiple select)
701 * The viewobject typically is an COM object with one of the following interfaces:
702 * IExtractIcon,IDataObject,IContextMenu
703 * In order to support icon positions in the default Listview your DataObject
704 * must implement the SetData method (in addition to GetData :) - the shell passes
705 * a barely documented "Icon positions" structure to SetData when the drag starts,
706 * and GetData's it if the drop is in another explorer window that needs the positions.
708 static HRESULT WINAPI IShellFolder_GetUIObjectOf(
712 LPCITEMIDLIST * apidl,
719 LPUNKNOWN pObj = NULL;
721 WINE_StringFromCLSID(riid,xclsid);
723 TRACE(shell,"(%p)->(%u,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
724 this,hwndOwner,cidl,apidl,xclsid,prgfInOut,ppvOut);
728 if(IsEqualIID(riid, &IID_IContextMenu))
733 pObj = (LPUNKNOWN)IContextMenu_Constructor(this, apidl, cidl);
735 else if (IsEqualIID(riid, &IID_IDataObject))
738 return(E_INVALIDARG);
740 pObj = (LPUNKNOWN)IDataObject_Constructor (hwndOwner, this, apidl, cidl);
742 else if(IsEqualIID(riid, &IID_IExtractIcon))
745 return(E_INVALIDARG);
747 pidl = ILCombine(this->pMyPidl,apidl[0]);
748 pObj = (LPUNKNOWN)IExtractIcon_Constructor( pidl );
751 else if (IsEqualIID(riid, &IID_IDropTarget))
754 return(E_INVALIDARG);
756 pObj = (LPUNKNOWN)ISFDropTarget_Constructor();
760 ERR(shell,"(%p)->E_NOINTERFACE\n",this);
761 return E_NOINTERFACE;
765 return E_OUTOFMEMORY;
770 /**************************************************************************
771 * IShellFolder_GetDisplayNameOf
772 * Retrieves the display name for the specified file object or subfolder
775 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
776 * DWORD dwFlags, //[in ] SHGNO formatting flags
777 * LPSTRRET lpName) //[out] Returned display name
780 * if the name is in the pidl the ret value should be a STRRET_OFFSET
782 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
783 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
785 static HRESULT WINAPI IShellFolder_GetDisplayNameOf( LPSHELLFOLDER this, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET lpName)
786 { CHAR szText[MAX_PATH];
787 CHAR szTemp[MAX_PATH];
788 CHAR szSpecial[MAX_PATH];
789 CHAR szDrive[MAX_PATH];
790 DWORD dwVolumeSerialNumber,dwMaximumComponetLength,dwFileSystemFlags;
791 LPITEMIDLIST pidlTemp=NULL;
792 BOOL bSimplePidl=FALSE;
794 TRACE(shell,"(%p)->(pidl=%p,0x%08lx,%p)\n",this,pidl,dwFlags,lpName);
802 /* test if simple(relative) or complex(absolute) pidl */
803 pidlTemp = ILGetNext(pidl);
804 if (pidlTemp && pidlTemp->mkid.cb==0x00)
805 { bSimplePidl = TRUE;
806 TRACE(shell,"-- simple pidl\n");
809 if (_ILIsDesktop( pidl))
810 { strcpy (szText,"Desktop");
813 { if (_ILIsMyComputer(pidl))
814 { _ILGetItemText(pidl, szSpecial, MAX_PATH);
815 pidl = ILGetNext(pidl);
818 if (_ILIsDrive(pidl))
819 { _ILGetDrive( pidl, szTemp, MAX_PATH);
821 if ( dwFlags==SHGDN_NORMAL || dwFlags==SHGDN_INFOLDER) /* like "A1-dos (C:)" */
822 { GetVolumeInformationA(szTemp,szDrive,MAX_PATH,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
823 szTemp[2]=0x00; /* overwrite '\' */
824 strcat (szDrive," (");
825 strcat (szDrive,szTemp);
826 strcat (szDrive,")");
828 else /* like "C:\" */
829 { PathAddBackslashA (szTemp);
830 strcpy(szDrive,szTemp);
836 { case SHGDN_NORMAL: /* 0x0000 */
837 _ILGetPidlPath( pidl, szText, MAX_PATH);
840 case SHGDN_INFOLDER | SHGDN_FORPARSING: /* 0x8001 */
841 case SHGDN_INFOLDER: /* 0x0001 */
842 pidlTemp = ILFindLastID(pidl);
844 { _ILGetItemText( pidlTemp, szText, MAX_PATH);
848 case SHGDN_FORPARSING: /* 0x8000 */
850 { /* if the IShellFolder has parents, get the path from the
851 parent and add the ItemName*/
853 if (this->sMyPath && strlen (this->sMyPath))
854 { if (strcmp(this->sMyPath,"My Computer"))
855 { strcpy (szText,this->sMyPath);
856 PathAddBackslashA (szText);
859 pidlTemp = ILFindLastID(pidl);
861 { _ILGetItemText( pidlTemp, szTemp, MAX_PATH );
863 strcat(szText,szTemp);
865 else /* if the pidl is absolute, get everything from the pidl*/
866 { _ILGetPidlPath( pidl, szText, MAX_PATH);
870 TRACE(shell,"--- wrong flags=%lx\n", dwFlags);
873 if ((szText[0]==0x00 && szDrive[0]!=0x00)|| (bSimplePidl && szDrive[0]!=0x00))
874 { strcpy(szText,szDrive);
876 if (szText[0]==0x00 && szSpecial[0]!=0x00)
877 { strcpy(szText,szSpecial);
881 TRACE(shell,"-- (%p)->(%s)\n",this,szText);
884 { return E_OUTOFMEMORY;
886 lpName->uType = STRRET_CSTRA;
887 strcpy(lpName->u.cStr,szText);
891 /**************************************************************************
892 * IShellFolder_SetNameOf
893 * Changes the name of a file object or subfolder, possibly changing its item
894 * identifier in the process.
897 * HWND hwndOwner, //[in ] Owner window for output
898 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
899 * LPCOLESTR lpszName, //[in ] the items new display name
900 * DWORD dwFlags, //[in ] SHGNO formatting flags
901 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
903 static HRESULT WINAPI IShellFolder_SetNameOf(
906 LPCITEMIDLIST pidl, /*simple pidl*/
909 LPITEMIDLIST *pPidlOut)
910 { FIXME(shell,"(%p)->(%u,pidl=%p,%s,%lu,%p),stub!\n",
911 this,hwndOwner,pidl,debugstr_w(lpName),dw,pPidlOut);
914 /**************************************************************************
915 * IShellFolder_GetFolderPath
916 * FIXME: drive not included
918 static BOOL WINAPI IShellFolder_GetFolderPath(LPSHELLFOLDER this, LPSTR lpszOut, DWORD dwOutSize)
921 TRACE(shell,"(%p)->(%p %lu)\n",this, lpszOut, dwOutSize);
931 dwSize = strlen (this->sMyPath) +1;
932 if ( dwSize > dwOutSize)
934 strcpy(lpszOut, this->sMyPath);
936 TRACE(shell,"-- (%p)->(return=%s)\n",this, lpszOut);