4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied
12 #include "debugtools.h"
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("(%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("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
86 TRACE("-- Interface: E_NOINTERFACE\n");
91 static ULONG WINAPI ISFDropTarget_AddRef( IDropTarget *iface)
93 ICOM_THIS(ISFDropTarget,iface);
95 TRACE("(%p)->(count=%lu)\n",This,This->ref);
102 static ULONG WINAPI ISFDropTarget_Release( IDropTarget *iface)
104 ICOM_THIS(ISFDropTarget,iface);
109 { TRACE("-- 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("Stub: This=%p, DataObject=%p\n",This,pDataObject);
131 static HRESULT WINAPI ISFDropTarget_DragOver(
137 ICOM_THIS(ISFDropTarget,iface);
139 FIXME("Stub: This=%p\n",This);
144 static HRESULT WINAPI ISFDropTarget_DragLeave(
147 ICOM_THIS(ISFDropTarget,iface);
149 FIXME("Stub: This=%p\n",This);
154 static HRESULT WINAPI ISFDropTarget_Drop(
156 IDataObject* pDataObject,
161 ICOM_THIS(ISFDropTarget,iface);
163 FIXME("Stub: This=%p\n",This);
168 static struct ICOM_VTABLE(IDropTarget) dtvt =
170 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
171 ISFDropTarget_QueryInterface,
172 ISFDropTarget_AddRef,
173 ISFDropTarget_Release,
174 ISFDropTarget_DragEnter,
175 ISFDropTarget_DragOver,
176 ISFDropTarget_DragLeave,
180 /***************************************************************************
181 * GetNextElement (internal function)
183 * gets a part of a string till the first backslash
186 * pszNext [IN] string to get the element from
187 * pszOut [IN] pointer to buffer whitch receives string
188 * dwOut [IN] length of pszOut
191 * LPSTR pointer to first, not yet parsed char
193 LPSTR GetNextElement(LPSTR pszNext,LPSTR pszOut,DWORD dwOut)
194 { LPSTR pszTail = pszNext;
196 TRACE("(%s %p 0x%08lx)\n",debugstr_a(pszNext),pszOut,dwOut);
198 if(!pszNext || !*pszNext)
201 while(*pszTail && (*pszTail != '\\'))
204 dwCopy=((LPBYTE)pszTail-(LPBYTE)pszNext)/sizeof(CHAR)+1;
205 lstrcpynA(pszOut, pszNext, (dwOut<dwCopy)? dwOut : dwCopy);
211 TRACE("--(%s %s 0x%08lx)\n",debugstr_a(pszNext),debugstr_a(pszOut),dwOut);
215 /***********************************************************************
216 * IShellFolder implementation
219 static struct ICOM_VTABLE(IShellFolder) sfvt;
220 static struct ICOM_VTABLE(IPersistFolder) psfvt;
222 #define _IPersistFolder_Offset ((int)(&(((IGenericSFImpl*)0)->lpvtblPersistFolder)))
223 #define _ICOM_THIS_From_IPersistFolder(class, name) class* This = (class*)(((char*)name)-_IPersistFolder_Offset);
225 /**************************************************************************
226 * IShellFolder_Constructor
229 IShellFolder * IShellFolder_Constructor(
230 IGenericSFImpl * pParent,
236 sf=(IGenericSFImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IGenericSFImpl));
239 sf->lpvtblPersistFolder=&psfvt;
240 sf->sMyPath=NULL; /* path of the folder */
241 sf->pMyPidl=NULL; /* my qualified pidl */
243 TRACE("(%p)->(parent=%p, pidl=%p)\n",sf,pParent, pidl);
246 /* keep a copy of the pidl in the instance*/
247 sf->mpidl = ILClone(pidl); /* my short pidl */
249 if(sf->mpidl) /* do we have a pidl? */
251 if(pParent->sMyPath) /* get the size of the parents path */
252 { dwSize += strlen(pParent->sMyPath) ;
253 TRACE("-- (%p)->(parent's path=%s)\n",sf, debugstr_a(pParent->sMyPath));
255 dwSize += _ILGetFolderText(sf->mpidl,NULL,0); /* add the size of the foldername*/
256 sf->sMyPath = SHAlloc(dwSize+2); /* '\0' and backslash */
260 if(pParent->sMyPath) /* if the parent has a path, get it*/
261 { strcpy(sf->sMyPath, pParent->sMyPath);
262 PathAddBackslashA (sf->sMyPath);
264 sf->pMyPidl = ILCombine(pParent->pMyPidl, pidl);
265 len = strlen(sf->sMyPath);
266 _ILGetFolderText(sf->mpidl, sf->sMyPath+len, dwSize-len);
267 TRACE("-- (%p)->(my pidl=%p, my path=%s)\n",sf, sf->pMyPidl,debugstr_a(sf->sMyPath));
272 return (IShellFolder *)sf;
274 /**************************************************************************
275 * IShellFolder_fnQueryInterface
278 * REFIID riid [in ] Requested InterfaceID
279 * LPVOID* ppvObject [out] Interface* to hold the result
281 static HRESULT WINAPI IShellFolder_fnQueryInterface(
282 IShellFolder * iface,
286 ICOM_THIS(IGenericSFImpl, iface);
289 WINE_StringFromCLSID((LPCLSID)riid,xriid);
290 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
294 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
297 else if(IsEqualIID(riid, &IID_IShellFolder)) /*IShellFolder*/
298 { *ppvObj = (IShellFolder*)This;
300 else if(IsEqualIID(riid, &IID_IPersistFolder)) /*IPersistFolder*/
301 { *ppvObj = (IPersistFolder*)&(This->lpvtblPersistFolder);
305 { IShellFolder_AddRef((IShellFolder*)*ppvObj);
306 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
309 TRACE("-- Interface: E_NOINTERFACE\n");
310 return E_NOINTERFACE;
313 /**************************************************************************
314 * IShellFolder::AddRef
317 static ULONG WINAPI IShellFolder_fnAddRef(IShellFolder * iface)
319 ICOM_THIS(IGenericSFImpl, iface);
321 TRACE("(%p)->(count=%lu)\n",This,This->ref);
324 return ++(This->ref);
327 /**************************************************************************
328 * IShellFolder_fnRelease
330 static ULONG WINAPI IShellFolder_fnRelease(IShellFolder * iface)
332 ICOM_THIS(IGenericSFImpl, iface);
334 TRACE("(%p)->(count=%lu)\n",This,This->ref);
338 { TRACE("-- destroying IShellFolder(%p)\n",This);
340 if (pdesktopfolder == iface)
341 { pdesktopfolder=NULL;
342 TRACE("-- 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_fnParseDisplayName
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_fnParseDisplayName(
374 IShellFolder * iface,
377 LPOLESTR lpszDisplayName,
380 DWORD *pdwAttributes)
382 ICOM_THIS(IGenericSFImpl, iface);
384 HRESULT hr=E_OUTOFMEMORY;
385 LPITEMIDLIST pidlFull=NULL, pidlTemp = NULL, pidlOld = NULL;
387 CHAR szTemp[MAX_PATH],szElement[MAX_PATH];
390 TRACE("(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
391 This,hwndOwner,pbcReserved,lpszDisplayName,
392 debugstr_w(lpszDisplayName),pchEaten,ppidl,pdwAttributes);
395 WideCharToLocal(szTemp, lpszDisplayName, lstrlenW(lpszDisplayName) + 1);
397 { if (strcmp(szTemp,"Desktop")==0)
398 { pidlFull = _ILCreateDesktop();
400 else if (strcmp(szTemp,"My Computer")==0)
401 { pidlFull = _ILCreateMyComputer();
404 { if (!PathIsRootA(szTemp))
405 { if (This->sMyPath && strlen (This->sMyPath))
406 { if (strcmp(This->sMyPath,"My Computer"))
407 { strcpy (szElement,This->sMyPath);
408 PathAddBackslashA (szElement);
409 strcat (szElement, szTemp);
410 strcpy (szTemp, szElement);
415 /* check if the lpszDisplayName is Folder or File*/
416 bIsFile = ! (GetFileAttributesA(szTemp) & FILE_ATTRIBUTE_DIRECTORY);
417 pszNext = GetNextElement(szTemp, szElement, MAX_PATH);
419 pidlFull = _ILCreateMyComputer();
420 pidlTemp = _ILCreateDrive(szElement);
422 pidlFull = ILCombine(pidlFull,pidlTemp);
426 { while((pszNext=GetNextElement(pszNext, szElement, MAX_PATH)))
427 { if(!*pszNext && bIsFile)
428 { pidlTemp = _ILCreateValue(NULL, szElement); /* FIXME: shortname */
431 { pidlTemp = _ILCreateFolder(NULL, szElement); /* FIXME: shortname */
434 pidlFull = ILCombine(pidlFull,pidlTemp);
446 /**************************************************************************
447 * IShellFolder_fnEnumObjects
449 * HWND hwndOwner, //[in ] Parent Window
450 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
451 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
453 static HRESULT WINAPI IShellFolder_fnEnumObjects(
454 IShellFolder * iface,
457 LPENUMIDLIST* ppEnumIDList)
459 ICOM_THIS(IGenericSFImpl, iface);
461 TRACE("(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",This,hwndOwner,dwFlags,ppEnumIDList);
463 *ppEnumIDList = NULL;
464 *ppEnumIDList = IEnumIDList_Constructor (This->sMyPath, dwFlags);
465 TRACE("-- (%p)->(new ID List: %p)\n",This,*ppEnumIDList);
467 { return E_OUTOFMEMORY;
472 /**************************************************************************
473 * IShellFolder_fnBindToObject
475 * LPCITEMIDLIST pidl, //[in ] complex pidl to open
476 * LPBC pbc, //[in ] reserved
477 * REFIID riid, //[in ] Initial Interface
478 * LPVOID* ppvObject //[out] Interface*
480 static HRESULT WINAPI IShellFolder_fnBindToObject( IShellFolder * iface, LPCITEMIDLIST pidl,
481 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
483 ICOM_THIS(IGenericSFImpl, iface);
487 LPSHELLFOLDER pShellFolder;
489 WINE_StringFromCLSID(riid,xriid);
491 TRACE("(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",This,pidl,pbcReserved,xriid,ppvOut);
495 pShellFolder = IShellFolder_Constructor(This, pidl);
498 return E_OUTOFMEMORY;
500 hr = pShellFolder->lpvtbl->fnQueryInterface(pShellFolder, riid, ppvOut);
501 pShellFolder->lpvtbl->fnRelease(pShellFolder);
502 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
506 /**************************************************************************
507 * IShellFolder_fnBindToStorage
509 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
510 * LPBC pbc, //[in ] reserved
511 * REFIID riid, //[in ] Initial storage interface
512 * LPVOID* ppvObject //[out] Interface* returned
514 static HRESULT WINAPI IShellFolder_fnBindToStorage(
515 IShellFolder * iface,
521 ICOM_THIS(IGenericSFImpl, iface);
524 WINE_StringFromCLSID(riid,xriid);
526 FIXME("(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",This,pidl,pbcReserved,xriid,ppvOut);
532 /**************************************************************************
533 * IShellFolder_fnCompareIDs
536 * LPARAM lParam, //[in ] Column?
537 * LPCITEMIDLIST pidl1, //[in ] simple pidl
538 * LPCITEMIDLIST pidl2) //[in ] simple pidl
541 * Special case - If one of the items is a Path and the other is a File,
542 * always make the Path come before the File.
545 * we have to handle simple pidl's only (?)
547 static HRESULT WINAPI IShellFolder_fnCompareIDs(
548 IShellFolder * iface,
553 ICOM_THIS(IGenericSFImpl, iface);
555 CHAR szString1[MAX_PATH] = "";
556 CHAR szString2[MAX_PATH] = "";
558 LPCITEMIDLIST pidlTemp1 = pidl1, pidlTemp2 = pidl2;
560 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",This,lParam,pidl1,pidl2);
564 if (!pidl1 && !pidl2)
566 if (!pidl1) /* Desktop < anything */
571 /* get the last item in each list */
572 pidlTemp1 = ILFindLastID(pidlTemp1);
573 pidlTemp2 = ILFindLastID(pidlTemp2);
575 /* at This point, both pidlTemp1 and pidlTemp2 point to the last item in the list */
576 if(_ILIsValue(pidlTemp1) != _ILIsValue(pidlTemp2))
577 { if(_ILIsValue(pidlTemp1))
582 _ILGetDrive( pidl1,szString1,sizeof(szString1));
583 _ILGetDrive( pidl2,szString2,sizeof(szString2));
584 nReturn = strcasecmp(szString1, szString2);
589 _ILGetFolderText( pidl1,szString1,sizeof(szString1));
590 _ILGetFolderText( pidl2,szString2,sizeof(szString2));
591 nReturn = strcasecmp(szString1, szString2);
596 _ILGetValueText(pidl1,szString1,sizeof(szString1));
597 _ILGetValueText(pidl2,szString2,sizeof(szString2));
598 return strcasecmp(szString1, szString2);
601 /**************************************************************************
602 * IShellFolder_fnCreateViewObject
603 * Creates an View Object representing the ShellFolder
604 * IShellView / IShellBrowser / IContextMenu
607 * HWND hwndOwner, // Handle of owner window
608 * REFIID riid, // Requested initial interface
609 * LPVOID* ppvObject) // Resultant interface*
612 * the same as SHCreateShellFolderViewEx ???
614 static HRESULT WINAPI IShellFolder_fnCreateViewObject( IShellFolder * iface,
615 HWND hwndOwner, REFIID riid, LPVOID *ppvOut)
617 ICOM_THIS(IGenericSFImpl, iface);
619 LPSHELLVIEW pShellView;
623 WINE_StringFromCLSID(riid,xriid);
624 TRACE("(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",This,hwndOwner,xriid,ppvOut);
628 pShellView = IShellView_Constructor((IShellFolder *) This, This->mpidl);
631 return E_OUTOFMEMORY;
633 hr = pShellView->lpvtbl->fnQueryInterface(pShellView, riid, ppvOut);
634 pShellView->lpvtbl->fnRelease(pShellView);
635 TRACE("-- (%p)->(interface=%p)\n",This, ppvOut);
639 /**************************************************************************
640 * IShellFolder_fnGetAttributesOf
643 * UINT cidl, //[in ] num elements in pidl array
644 + LPCITEMIDLIST* apidl, //[in ] simple pidl array
645 * ULONG* rgfInOut) //[out] result array
648 * Note: rgfInOut is documented as being an array of ULONGS.
649 * This does not seem to be the case. Testing This function using the shell to
650 * call it with cidl > 1 (by deleting multiple items) reveals that the shell
651 * passes ONE element in the array and writing to further elements will
652 * cause the shell to fail later.
654 static HRESULT WINAPI IShellFolder_fnGetAttributesOf(IShellFolder * iface,UINT cidl,LPCITEMIDLIST *apidl,DWORD *rgfInOut)
656 ICOM_THIS(IGenericSFImpl, iface);
658 LPCITEMIDLIST * pidltemp;
661 TRACE("(%p)->(%d,%p,%p)\n",This,cidl,apidl,rgfInOut);
663 if ( (!cidl) || (!apidl) || (!rgfInOut))
670 TRACE("-- mask=0x%08lx\n",*rgfInOut);
675 if (_ILIsDesktop( *pidltemp))
676 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
678 else if (_ILIsMyComputer( *pidltemp))
679 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
680 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANRENAME | SFGAO_CANLINK );
682 else if (_ILIsDrive( *pidltemp))
683 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR |
684 SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANLINK );
686 else if (_ILIsFolder( *pidltemp))
687 { *rgfInOut |= ( SFGAO_HASSUBFOLDER | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_CAPABILITYMASK );
689 else if (_ILIsValue( *pidltemp))
690 { *rgfInOut |= (SFGAO_FILESYSTEM | SFGAO_CAPABILITYMASK );
695 } while (cidl > 0 && *pidltemp);
699 /**************************************************************************
700 * IShellFolder_fnGetUIObjectOf
703 * HWND hwndOwner, //[in ] Parent window for any output
704 * UINT cidl, //[in ] array size
705 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
706 * REFIID riid, //[in ] Requested Interface
707 * UINT* prgfInOut, //[ ] reserved
708 * LPVOID* ppvObject) //[out] Resulting Interface
711 * This function gets asked to return "view objects" for one or more (multiple select)
713 * The viewobject typically is an COM object with one of the following interfaces:
714 * IExtractIcon,IDataObject,IContextMenu
715 * In order to support icon positions in the default Listview your DataObject
716 * must implement the SetData method (in addition to GetData :) - the shell passes
717 * a barely documented "Icon positions" structure to SetData when the drag starts,
718 * and GetData's it if the drop is in another explorer window that needs the positions.
720 static HRESULT WINAPI IShellFolder_fnGetUIObjectOf(
721 IShellFolder * iface,
724 LPCITEMIDLIST * apidl,
729 ICOM_THIS(IGenericSFImpl, iface);
733 LPUNKNOWN pObj = NULL;
735 WINE_StringFromCLSID(riid,xclsid);
737 TRACE("(%p)->(%u,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
738 This,hwndOwner,cidl,apidl,xclsid,prgfInOut,ppvOut);
742 if(IsEqualIID(riid, &IID_IContextMenu))
747 pObj = (LPUNKNOWN)IContextMenu_Constructor((IShellFolder *)This, apidl, cidl);
749 else if (IsEqualIID(riid, &IID_IDataObject))
752 return(E_INVALIDARG);
754 pObj = (LPUNKNOWN)IDataObject_Constructor (hwndOwner, (IShellFolder *)This, apidl, cidl);
756 else if(IsEqualIID(riid, &IID_IExtractIconA))
759 return(E_INVALIDARG);
761 pidl = ILCombine(This->pMyPidl,apidl[0]);
762 pObj = (LPUNKNOWN)IExtractIconA_Constructor( pidl );
765 else if (IsEqualIID(riid, &IID_IDropTarget))
768 return(E_INVALIDARG);
770 pObj = (LPUNKNOWN)ISFDropTarget_Constructor();
774 ERR("(%p)->E_NOINTERFACE\n",This);
775 return E_NOINTERFACE;
779 return E_OUTOFMEMORY;
784 /**************************************************************************
785 * IShellFolder_fnGetDisplayNameOf
786 * Retrieves the display name for the specified file object or subfolder
789 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
790 * DWORD dwFlags, //[in ] SHGNO formatting flags
791 * LPSTRRET lpName) //[out] Returned display name
794 * if the name is in the pidl the ret value should be a STRRET_OFFSET
796 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
797 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
799 static HRESULT WINAPI IShellFolder_fnGetDisplayNameOf(
800 IShellFolder * iface,
805 ICOM_THIS(IGenericSFImpl, iface);
807 CHAR szText[MAX_PATH];
808 CHAR szTemp[MAX_PATH];
809 CHAR szSpecial[MAX_PATH];
810 CHAR szDrive[MAX_PATH];
811 DWORD dwVolumeSerialNumber,dwMaximumComponetLength,dwFileSystemFlags;
812 LPITEMIDLIST pidlTemp=NULL;
813 BOOL bSimplePidl=FALSE;
815 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n",This,pidl,dwFlags,lpName);
823 /* test if simple(relative) or complex(absolute) pidl */
824 pidlTemp = ILGetNext(pidl);
825 if (pidlTemp && pidlTemp->mkid.cb==0x00)
826 { bSimplePidl = TRUE;
827 TRACE("-- simple pidl\n");
830 if (_ILIsDesktop( pidl))
831 { strcpy (szText,"Desktop");
834 { if (_ILIsMyComputer(pidl))
835 { _ILGetItemText(pidl, szSpecial, MAX_PATH);
836 pidl = ILGetNext(pidl);
839 if (_ILIsDrive(pidl))
840 { _ILGetDrive( pidl, szTemp, MAX_PATH);
842 if ( dwFlags==SHGDN_NORMAL || dwFlags==SHGDN_INFOLDER) /* like "A1-dos (C:)" */
843 { GetVolumeInformationA(szTemp,szDrive,MAX_PATH,&dwVolumeSerialNumber,&dwMaximumComponetLength,&dwFileSystemFlags,NULL,0);
844 szTemp[2]=0x00; /* overwrite '\' */
845 strcat (szDrive," (");
846 strcat (szDrive,szTemp);
847 strcat (szDrive,")");
849 else /* like "C:\" */
850 { PathAddBackslashA (szTemp);
851 strcpy(szDrive,szTemp);
857 { case SHGDN_NORMAL: /* 0x0000 */
858 _ILGetPidlPath( pidl, szText, MAX_PATH);
861 case SHGDN_INFOLDER | SHGDN_FORPARSING: /* 0x8001 */
862 case SHGDN_INFOLDER: /* 0x0001 */
863 pidlTemp = ILFindLastID(pidl);
865 { _ILGetItemText( pidlTemp, szText, MAX_PATH);
869 case SHGDN_FORPARSING: /* 0x8000 */
871 { /* if the IShellFolder has parents, get the path from the
872 parent and add the ItemName*/
874 if (This->sMyPath && strlen (This->sMyPath))
875 { if (strcmp(This->sMyPath,"My Computer"))
876 { strcpy (szText,This->sMyPath);
877 PathAddBackslashA (szText);
880 pidlTemp = ILFindLastID(pidl);
882 { _ILGetItemText( pidlTemp, szTemp, MAX_PATH );
884 strcat(szText,szTemp);
886 else /* if the pidl is absolute, get everything from the pidl*/
887 { _ILGetPidlPath( pidl, szText, MAX_PATH);
891 TRACE("--- wrong flags=%lx\n", dwFlags);
894 if ((szText[0]==0x00 && szDrive[0]!=0x00)|| (bSimplePidl && szDrive[0]!=0x00))
895 { strcpy(szText,szDrive);
897 if (szText[0]==0x00 && szSpecial[0]!=0x00)
898 { strcpy(szText,szSpecial);
902 TRACE("-- (%p)->(%s)\n",This,szText);
905 { return E_OUTOFMEMORY;
907 lpName->uType = STRRET_CSTRA;
908 strcpy(lpName->u.cStr,szText);
912 /**************************************************************************
913 * IShellFolder_fnSetNameOf
914 * Changes the name of a file object or subfolder, possibly changing its item
915 * identifier in the process.
918 * HWND hwndOwner, //[in ] Owner window for output
919 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
920 * LPCOLESTR lpszName, //[in ] the items new display name
921 * DWORD dwFlags, //[in ] SHGNO formatting flags
922 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
924 static HRESULT WINAPI IShellFolder_fnSetNameOf(
925 IShellFolder * iface,
927 LPCITEMIDLIST pidl, /*simple pidl*/
930 LPITEMIDLIST *pPidlOut)
932 ICOM_THIS(IGenericSFImpl, iface);
934 FIXME("(%p)->(%u,pidl=%p,%s,%lu,%p),stub!\n",
935 This,hwndOwner,pidl,debugstr_w(lpName),dw,pPidlOut);
940 /**************************************************************************
941 * IShellFolder_fnGetFolderPath
942 * FIXME: drive not included
944 static HRESULT WINAPI IShellFolder_fnGetFolderPath(IShellFolder * iface, LPSTR lpszOut, DWORD dwOutSize)
946 ICOM_THIS(IGenericSFImpl, iface);
949 TRACE("(%p)->(%p %lu)\n",This, lpszOut, dwOutSize);
959 dwSize = strlen (This->sMyPath) +1;
960 if ( dwSize > dwOutSize)
962 strcpy(lpszOut, This->sMyPath);
964 TRACE("-- (%p)->(return=%s)\n",This, lpszOut);
968 static ICOM_VTABLE(IShellFolder) sfvt =
970 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
971 IShellFolder_fnQueryInterface,
972 IShellFolder_fnAddRef,
973 IShellFolder_fnRelease,
974 IShellFolder_fnParseDisplayName,
975 IShellFolder_fnEnumObjects,
976 IShellFolder_fnBindToObject,
977 IShellFolder_fnBindToStorage,
978 IShellFolder_fnCompareIDs,
979 IShellFolder_fnCreateViewObject,
980 IShellFolder_fnGetAttributesOf,
981 IShellFolder_fnGetUIObjectOf,
982 IShellFolder_fnGetDisplayNameOf,
983 IShellFolder_fnSetNameOf,
984 IShellFolder_fnGetFolderPath
987 /************************************************************************
988 * ISFPersistFolder_QueryInterface (IUnknown)
990 * See Windows documentation for more details on IUnknown methods.
992 static HRESULT WINAPI ISFPersistFolder_QueryInterface(
993 IPersistFolder * iface,
997 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
999 return IShellFolder_QueryInterface((IShellFolder*)This, iid, ppvObj);
1002 /************************************************************************
1003 * ISFPersistFolder_AddRef (IUnknown)
1005 * See Windows documentation for more details on IUnknown methods.
1007 static ULONG WINAPI ISFPersistFolder_AddRef(
1008 IPersistFolder * iface)
1010 _ICOM_THIS_From_IPersistFolder(IShellFolder, iface);
1012 return IShellFolder_AddRef((IShellFolder*)This);
1015 /************************************************************************
1016 * ISFPersistFolder_Release (IUnknown)
1018 * See Windows documentation for more details on IUnknown methods.
1020 static ULONG WINAPI ISFPersistFolder_Release(
1021 IPersistFolder * iface)
1023 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1025 return IShellFolder_Release((IShellFolder*)This);
1028 /************************************************************************
1029 * ISFPersistFolder_GetClassID (IPersist)
1031 * See Windows documentation for more details on IPersist methods.
1033 static HRESULT WINAPI ISFPersistFolder_GetClassID(
1034 const IPersistFolder * iface,
1037 /* This ID is not documented anywhere but some tests in Windows tell
1038 * me that This is the ID for the "standard" implementation of the
1039 * IFolder interface.
1042 CLSID StdFolderID = { 0xF3364BA0, 0x65B9, 0x11CE, {0xA9, 0xBA, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37} };
1044 if (lpClassId==NULL)
1047 memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
1052 /************************************************************************
1053 * ISFPersistFolder_Initialize (IPersistFolder)
1055 * See Windows documentation for more details on IPersistFolder methods.
1057 static HRESULT WINAPI ISFPersistFolder_Initialize(
1058 IPersistFolder * iface,
1061 _ICOM_THIS_From_IPersistFolder(IGenericSFImpl, iface);
1064 { SHFree(This->pMyPidl);
1065 This->pMyPidl = NULL;
1067 This->pMyPidl = ILClone(pidl);
1071 static ICOM_VTABLE(IPersistFolder) psfvt =
1073 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1074 ISFPersistFolder_QueryInterface,
1075 ISFPersistFolder_AddRef,
1076 ISFPersistFolder_Release,
1077 ISFPersistFolder_GetClassID,
1078 ISFPersistFolder_Initialize