4 * Copyright 1997 Marcus Meissner
5 * Copyright 1998 Juergen Schmied
23 #include "shell32_main.h"
25 static HRESULT WINAPI
IShellFolder_QueryInterface(LPSHELLFOLDER
,REFIID
,LPVOID
*);
26 static ULONG WINAPI
IShellFolder_AddRef(LPSHELLFOLDER
);
27 static ULONG WINAPI
IShellFolder_Release(LPSHELLFOLDER
);
28 static HRESULT WINAPI
IShellFolder_Initialize(LPSHELLFOLDER
,LPCITEMIDLIST
);
29 static HRESULT WINAPI
IShellFolder_ParseDisplayName(LPSHELLFOLDER
,HWND32
,LPBC
,LPOLESTR32
,DWORD
*,LPITEMIDLIST
*,DWORD
*);
30 static HRESULT WINAPI
IShellFolder_EnumObjects(LPSHELLFOLDER
,HWND32
,DWORD
,LPENUMIDLIST
*);
31 static HRESULT WINAPI
IShellFolder_BindToObject(LPSHELLFOLDER
,LPCITEMIDLIST
,LPBC
,REFIID
,LPVOID
*);
32 static HRESULT WINAPI
IShellFolder_BindToStorage(LPSHELLFOLDER
,LPCITEMIDLIST
,LPBC
,REFIID
,LPVOID
*);
33 static HRESULT WINAPI
IShellFolder_CompareIDs(LPSHELLFOLDER
,LPARAM
,LPCITEMIDLIST
,LPCITEMIDLIST
);
34 static HRESULT WINAPI
IShellFolder_CreateViewObject(LPSHELLFOLDER
,HWND32
,REFIID
,LPVOID
*);
35 static HRESULT WINAPI
IShellFolder_GetAttributesOf(LPSHELLFOLDER
,UINT32
,LPCITEMIDLIST
*,DWORD
*);
36 static HRESULT WINAPI
IShellFolder_GetUIObjectOf(LPSHELLFOLDER
,HWND32
,UINT32
,LPCITEMIDLIST
*,REFIID
,UINT32
*,LPVOID
*);
37 static HRESULT WINAPI
IShellFolder_GetDisplayNameOf(LPSHELLFOLDER
,LPCITEMIDLIST
,DWORD
,LPSTRRET
);
38 static HRESULT WINAPI
IShellFolder_SetNameOf(LPSHELLFOLDER
,HWND32
,LPCITEMIDLIST
,LPCOLESTR32
,DWORD
,LPITEMIDLIST
*);
39 static BOOL32 WINAPI
IShellFolder_GetFolderPath(LPSHELLFOLDER
,LPSTR
,DWORD
);
41 /***************************************************************************
42 * GetNextElement (internal function)
44 * gets a part of a string till the first backslash
47 * pszNext [IN] string to get the element from
48 * pszOut [IN] pointer to buffer whitch receives string
49 * dwOut [IN] length of pszOut
52 * LPSTR pointer to first, not yet parsed char
54 LPSTR
GetNextElement(LPSTR pszNext
,LPSTR pszOut
,DWORD dwOut
)
55 { LPSTR pszTail
= pszNext
;
57 TRACE(shell
,"(%s %p 0x%08lx)\n",debugstr_a(pszNext
),pszOut
,dwOut
);
59 if(!pszNext
|| !*pszNext
)
62 while(*pszTail
&& (*pszTail
!= '\\'))
65 dwCopy
=((LPBYTE
)pszTail
-(LPBYTE
)pszNext
)/sizeof(CHAR
)+1;
66 lstrcpyn32A(pszOut
, pszNext
, (dwOut
<dwCopy
)? dwOut
: dwCopy
);
72 TRACE(shell
,"--(%s %s 0x%08lx)\n",debugstr_a(pszNext
),debugstr_a(pszOut
),dwOut
);
76 /***********************************************************************
77 * IShellFolder implementation
79 static struct IShellFolder_VTable sfvt
=
80 { IShellFolder_QueryInterface
,
83 IShellFolder_ParseDisplayName
,
84 IShellFolder_EnumObjects
,
85 IShellFolder_BindToObject
,
86 IShellFolder_BindToStorage
,
87 IShellFolder_CompareIDs
,
88 IShellFolder_CreateViewObject
,
89 IShellFolder_GetAttributesOf
,
90 IShellFolder_GetUIObjectOf
,
91 IShellFolder_GetDisplayNameOf
,
92 IShellFolder_SetNameOf
,
93 IShellFolder_GetFolderPath
95 /**************************************************************************
96 * IShellFolder_Constructor
99 LPSHELLFOLDER
IShellFolder_Constructor(LPSHELLFOLDER pParent
,LPITEMIDLIST pidl
)
102 sf
=(LPSHELLFOLDER
)HeapAlloc(GetProcessHeap(),0,sizeof(IShellFolder
));
105 sf
->sMyPath
=NULL
; /* path of the folder */
106 sf
->pMyPidl
=NULL
; /* my qualified pidl */
107 sf
->mpSFParent
=pParent
; /* parrent shellfolder */
109 TRACE(shell
,"(%p)->(parent=%p, pidl=%p)\n",sf
,pParent
, pidl
);
111 /* keep a copy of the pidl in the instance*/
112 sf
->mpidl
= ILClone(pidl
);
114 if(sf
->mpidl
) /* do we have a pidl? */
116 if(sf
->mpSFParent
->sMyPath
) /* get the size of the parents path */
117 { dwSize
+= strlen(sf
->mpSFParent
->sMyPath
) ;
118 TRACE(shell
,"-- (%p)->(parent's path=%s)\n",sf
, debugstr_a(sf
->mpSFParent
->sMyPath
));
120 dwSize
+= _ILGetFolderText(sf
->mpidl
,NULL
,0); /* add the size of the foldername*/
121 sf
->sMyPath
= SHAlloc(dwSize
+1);
123 { *(sf
->sMyPath
)=0x00;
124 if(sf
->mpSFParent
->sMyPath
) /* if the parent has a path, get it*/
125 { strcpy(sf
->sMyPath
, sf
->mpSFParent
->sMyPath
);
126 PathAddBackslash32A (sf
->sMyPath
);
128 sf
->pMyPidl
= ILCombine(sf
->pMyPidl
, pidl
);
129 _ILGetFolderText(sf
->mpidl
, sf
->sMyPath
+strlen(sf
->sMyPath
), dwSize
-strlen(sf
->sMyPath
));
130 TRACE(shell
,"-- (%p)->(my path=%s)\n",sf
, debugstr_a(sf
->sMyPath
));
135 /**************************************************************************
136 * IShellFolder::QueryInterface
138 * REFIID riid, //[in ] Requested InterfaceID
139 * LPVOID* ppvObject) //[out] Interface* to hold the result
141 static HRESULT WINAPI
IShellFolder_QueryInterface(
142 LPSHELLFOLDER
this, REFIID riid
, LPVOID
*ppvObj
)
144 WINE_StringFromCLSID((LPCLSID
)riid
,xriid
);
145 TRACE(shell
,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid
,ppvObj
);
149 if(IsEqualIID(riid
, &IID_IUnknown
)) /*IUnknown*/
152 else if(IsEqualIID(riid
, &IID_IShellFolder
)) /*IShellFolder*/
153 { *ppvObj
= (IShellFolder
*)this;
157 { (*(LPSHELLFOLDER
*)ppvObj
)->lpvtbl
->fnAddRef(this);
158 TRACE(shell
,"-- Interface: (%p)->(%p)\n",ppvObj
,*ppvObj
);
161 TRACE(shell
,"-- Interface: E_NOINTERFACE\n");
162 return E_NOINTERFACE
;
165 /**************************************************************************
166 * IShellFolder::AddRef
169 static ULONG WINAPI
IShellFolder_AddRef(LPSHELLFOLDER
this)
170 { TRACE(shell
,"(%p)->(count=%lu)\n",this,(this->ref
)+1);
171 return ++(this->ref
);
174 /**************************************************************************
175 * IShellFolder_Release
177 static ULONG WINAPI
IShellFolder_Release(LPSHELLFOLDER
this)
178 { TRACE(shell
,"(%p)->(count=%lu)\n",this,this->ref
);
180 { TRACE(shell
,"-- destroying IShellFolder(%p)\n",this);
182 if (pdesktopfolder
==this)
183 { pdesktopfolder
=NULL
;
184 TRACE(shell
,"-- destroyed IShellFolder(%p) was Desktopfolder\n",this);
187 { SHFree(this->pMyPidl
);
190 { SHFree(this->mpidl
);
193 { SHFree(this->sMyPath
);
196 HeapFree(GetProcessHeap(),0,this);
202 /**************************************************************************
203 * IShellFolder_ParseDisplayName
205 * HWND hwndOwner, //[in ] Parent window for any message's
206 * LPBC pbc, //[in ] reserved
207 * LPOLESTR lpszDisplayName,//[in ] "Unicode" displayname.
208 * ULONG* pchEaten, //[out] (unicode) characters processed
209 * LPITEMIDLIST* ppidl, //[out] complex pidl to item
210 * ULONG* pdwAttributes //[out] items attributes
213 * pdwAttributes: not used
215 static HRESULT WINAPI
IShellFolder_ParseDisplayName(
219 LPOLESTR32 lpszDisplayName
,
222 DWORD
*pdwAttributes
)
223 { HRESULT hr
=E_OUTOFMEMORY
;
224 LPITEMIDLIST pidlFull
=NULL
, pidlTemp
= NULL
, pidlOld
= NULL
;
226 CHAR szTemp
[MAX_PATH
],szElement
[MAX_PATH
];
229 TRACE(shell
,"(%p)->(HWND=0x%08x,%p,%p=%s,%p,pidl=%p,%p)\n",
230 this,hwndOwner
,pbcReserved
,lpszDisplayName
,
231 debugstr_w(lpszDisplayName
),pchEaten
,ppidl
,pdwAttributes
);
234 WideCharToLocal32(szTemp
, lpszDisplayName
, lstrlen32W(lpszDisplayName
) + 1);
236 { if (strcmp(szTemp
,"Desktop")==0)
237 { pidlFull
= _ILCreateDesktop();
239 else if (strcmp(szTemp
,"My Computer")==0)
240 { pidlFull
= _ILCreateMyComputer();
243 { if (!PathIsRoot32A(szTemp
))
244 { if (this->sMyPath
&& strlen (this->sMyPath
))
245 { if (strcmp(this->sMyPath
,"My Computer"))
246 { strcpy (szElement
,this->sMyPath
);
247 PathAddBackslash32A (szElement
);
248 strcat (szElement
, szTemp
);
249 strcpy (szTemp
, szElement
);
254 /* check if the lpszDisplayName is Folder or File*/
255 bIsFile
= ! (GetFileAttributes32A(szTemp
) & FILE_ATTRIBUTE_DIRECTORY
);
256 pszNext
= GetNextElement(szTemp
, szElement
, MAX_PATH
);
258 pidlFull
= _ILCreateMyComputer();
259 pidlTemp
= _ILCreateDrive(szElement
);
261 pidlFull
= ILCombine(pidlFull
,pidlTemp
);
265 { while((pszNext
=GetNextElement(pszNext
, szElement
, MAX_PATH
)))
266 { if(!*pszNext
&& bIsFile
)
267 { pidlTemp
= _ILCreateValue(szElement
);
270 { pidlTemp
= _ILCreateFolder(szElement
);
273 pidlFull
= ILCombine(pidlFull
,pidlTemp
);
285 /**************************************************************************
286 * IShellFolder_EnumObjects
288 * HWND hwndOwner, //[in ] Parent Window
289 * DWORD grfFlags, //[in ] SHCONTF enumeration mask
290 * LPENUMIDLIST* ppenumIDList //[out] IEnumIDList interface
292 static HRESULT WINAPI
IShellFolder_EnumObjects(
296 LPENUMIDLIST
* ppEnumIDList
)
297 { TRACE(shell
,"(%p)->(HWND=0x%08x flags=0x%08lx pplist=%p)\n",this,hwndOwner
,dwFlags
,ppEnumIDList
);
299 *ppEnumIDList
= NULL
;
300 *ppEnumIDList
= IEnumIDList_Constructor (this->sMyPath
, dwFlags
);
301 TRACE(shell
,"-- (%p)->(new ID List: %p)\n",this,*ppEnumIDList
);
303 { return E_OUTOFMEMORY
;
307 /**************************************************************************
308 * IShellFolder_Initialize()
309 * IPersistFolder Method
311 static HRESULT WINAPI
IShellFolder_Initialize( LPSHELLFOLDER
this,LPCITEMIDLIST pidl
)
312 { TRACE(shell
,"(%p)->(pidl=%p)\n",this,pidl
);
315 { SHFree(this->pMyPidl
);
316 this->pMyPidl
= NULL
;
318 this->pMyPidl
= ILClone(pidl
);
322 /**************************************************************************
323 * IShellFolder_BindToObject
325 * LPCITEMIDLIST pidl, //[in ] complex pidl to open
326 * LPBC pbc, //[in ] reserved
327 * REFIID riid, //[in ] Initial Interface
328 * LPVOID* ppvObject //[out] Interface*
330 static HRESULT WINAPI
IShellFolder_BindToObject( LPSHELLFOLDER
this, LPCITEMIDLIST pidl
,
331 LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
334 LPSHELLFOLDER pShellFolder
;
336 WINE_StringFromCLSID(riid
,xriid
);
338 TRACE(shell
,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p)\n",this,pidl
,pbcReserved
,xriid
,ppvOut
);
342 pShellFolder
= IShellFolder_Constructor(this, pidl
);
345 return E_OUTOFMEMORY
;
347 IShellFolder_Initialize(pShellFolder
, this->pMyPidl
);
349 hr
= pShellFolder
->lpvtbl
->fnQueryInterface(pShellFolder
, riid
, ppvOut
);
350 pShellFolder
->lpvtbl
->fnRelease(pShellFolder
);
351 TRACE(shell
,"-- (%p)->(interface=%p)\n",this, ppvOut
);
355 /**************************************************************************
356 * IShellFolder_BindToStorage
358 * LPCITEMIDLIST pidl, //[in ] complex pidl to store
359 * LPBC pbc, //[in ] reserved
360 * REFIID riid, //[in ] Initial storage interface
361 * LPVOID* ppvObject //[out] Interface* returned
363 static HRESULT WINAPI
IShellFolder_BindToStorage(LPSHELLFOLDER
this,
364 LPCITEMIDLIST pidl
,LPBC pbcReserved
, REFIID riid
, LPVOID
*ppvOut
)
366 WINE_StringFromCLSID(riid
,xriid
);
368 FIXME(shell
,"(%p)->(pidl=%p,%p,\n\tIID:%s,%p) stub\n",this,pidl
,pbcReserved
,xriid
,ppvOut
);
374 /**************************************************************************
375 * IShellFolder_CompareIDs
378 * LPARAM lParam, //[in ] Column?
379 * LPCITEMIDLIST pidl1, //[in ] simple pidl
380 * LPCITEMIDLIST pidl2) //[in ] simple pidl
383 * Special case - If one of the items is a Path and the other is a File,
384 * always make the Path come before the File.
387 * we have to handle simple pidl's only (?)
389 static HRESULT WINAPI
IShellFolder_CompareIDs(LPSHELLFOLDER
this,
390 LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
391 { CHAR szString1
[MAX_PATH
] = "";
392 CHAR szString2
[MAX_PATH
] = "";
394 LPCITEMIDLIST pidlTemp1
= pidl1
, pidlTemp2
= pidl2
;
396 TRACE(shell
,"(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n",this,lParam
,pidl1
,pidl2
);
400 if (!pidl1
&& !pidl2
)
402 if (!pidl1
) /* Desktop < anything */
407 /* get the last item in each list */
408 while((ILGetNext(pidlTemp1
))->mkid
.cb
)
409 pidlTemp1
= ILGetNext(pidlTemp1
);
410 while((ILGetNext(pidlTemp2
))->mkid
.cb
)
411 pidlTemp2
= ILGetNext(pidlTemp2
);
413 /* at this point, both pidlTemp1 and pidlTemp2 point to the last item in the list */
414 if(_ILIsValue(pidlTemp1
) != _ILIsValue(pidlTemp2
))
415 { if(_ILIsValue(pidlTemp1
))
420 _ILGetDrive( pidl1
,szString1
,sizeof(szString1
));
421 _ILGetDrive( pidl2
,szString1
,sizeof(szString2
));
422 nReturn
= strcasecmp(szString1
, szString2
);
427 _ILGetFolderText( pidl1
,szString1
,sizeof(szString1
));
428 _ILGetFolderText( pidl2
,szString2
,sizeof(szString2
));
429 nReturn
= strcasecmp(szString1
, szString2
);
434 _ILGetValueText(pidl1
,szString1
,sizeof(szString1
));
435 _ILGetValueText(pidl2
,szString2
,sizeof(szString2
));
436 return strcasecmp(szString1
, szString2
);
439 /**************************************************************************
440 * IShellFolder_CreateViewObject
441 * Creates an View Object representing the ShellFolder
442 * IShellView / IShellBrowser / IContextMenu
445 * HWND hwndOwner, // Handle of owner window
446 * REFIID riid, // Requested initial interface
447 * LPVOID* ppvObject) // Resultant interface*
450 * the same as SHCreateShellFolderViewEx ???
452 static HRESULT WINAPI
IShellFolder_CreateViewObject( LPSHELLFOLDER
this,
453 HWND32 hwndOwner
, REFIID riid
, LPVOID
*ppvOut
)
454 { LPSHELLVIEW pShellView
;
458 WINE_StringFromCLSID(riid
,xriid
);
459 TRACE(shell
,"(%p)->(hwnd=0x%x,\n\tIID:\t%s,%p)\n",this,hwndOwner
,xriid
,ppvOut
);
463 pShellView
= IShellView_Constructor(this, this->mpidl
);
466 return E_OUTOFMEMORY
;
468 hr
= pShellView
->lpvtbl
->fnQueryInterface(pShellView
, riid
, ppvOut
);
469 pShellView
->lpvtbl
->fnRelease(pShellView
);
470 TRACE(shell
,"-- (%p)->(interface=%p)\n",this, ppvOut
);
474 /**************************************************************************
475 * IShellFolder_GetAttributesOf
478 * UINT cidl, //[in ] num elements in pidl array
479 + LPCITEMIDLIST* apidl, //[in ] simple pidl array
480 * ULONG* rgfInOut) //[out] result array
483 * Note: rgfInOut is documented as being an array of ULONGS.
484 * This does not seem to be the case. Testing this function using the shell to
485 * call it with cidl > 1 (by deleting multiple items) reveals that the shell
486 * passes ONE element in the array and writing to further elements will
487 * cause the shell to fail later.
489 static HRESULT WINAPI
IShellFolder_GetAttributesOf(LPSHELLFOLDER
this,UINT32 cidl
,LPCITEMIDLIST
*apidl
,DWORD
*rgfInOut
)
490 { LPCITEMIDLIST
* pidltemp
;
493 TRACE(shell
,"(%p)->(%d,%p,%p)\n",this,cidl
,apidl
,rgfInOut
);
495 if ((! cidl
)| (!apidl
) | (!rgfInOut
))
502 TRACE(shell
,"-- mask=0x%08lx\n",*rgfInOut
);
507 if (_ILIsDesktop( *pidltemp
))
508 { *rgfInOut
|= ( SFGAO_HASSUBFOLDER
| SFGAO_FOLDER
| SFGAO_DROPTARGET
| SFGAO_HASPROPSHEET
| SFGAO_CANLINK
);
510 else if (_ILIsMyComputer( *pidltemp
))
511 { *rgfInOut
|= ( SFGAO_HASSUBFOLDER
| SFGAO_FOLDER
| SFGAO_FILESYSANCESTOR
512 | SFGAO_DROPTARGET
| SFGAO_HASPROPSHEET
| SFGAO_CANRENAME
| SFGAO_CANLINK
);
514 else if (_ILIsDrive( *pidltemp
))
515 { *rgfInOut
|= ( SFGAO_HASSUBFOLDER
| SFGAO_FILESYSTEM
| SFGAO_FOLDER
| SFGAO_FILESYSANCESTOR
|
516 SFGAO_DROPTARGET
| SFGAO_HASPROPSHEET
| SFGAO_CANLINK
);
518 else if (_ILIsFolder( *pidltemp
))
519 { *rgfInOut
|= ( SFGAO_HASSUBFOLDER
| SFGAO_FILESYSTEM
| SFGAO_FOLDER
| SFGAO_CAPABILITYMASK
);
521 else if (_ILIsValue( *pidltemp
))
522 { *rgfInOut
|= (SFGAO_FILESYSTEM
| SFGAO_CAPABILITYMASK
);
527 } while (cidl
> 0 && *pidltemp
);
531 /**************************************************************************
532 * IShellFolder_GetUIObjectOf
535 * HWND hwndOwner, //[in ] Parent window for any output
536 * UINT cidl, //[in ] array size
537 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
538 * REFIID riid, //[in ] Requested Interface
539 * UINT* prgfInOut, //[ ] reserved
540 * LPVOID* ppvObject) //[out] Resulting Interface
543 * This function gets asked to return "view objects" for one or more (multiple select)
545 * The viewobject typically is an COM object with one of the following interfaces:
546 * IExtractIcon,IDataObject,IContextMenu
547 * In order to support icon positions in the default Listview your DataObject
548 * must implement the SetData method (in addition to GetData :) - the shell passes
549 * a barely documented "Icon positions" structure to SetData when the drag starts,
550 * and GetData's it if the drop is in another explorer window that needs the positions.
552 static HRESULT WINAPI
IShellFolder_GetUIObjectOf( LPSHELLFOLDER
this,HWND32 hwndOwner
,UINT32 cidl
,
553 LPCITEMIDLIST
* apidl
, REFIID riid
, UINT32
* prgfInOut
,LPVOID
* ppvOut
)
556 LPUNKNOWN pObj
= NULL
;
558 WINE_StringFromCLSID(riid
,xclsid
);
560 TRACE(shell
,"(%p)->(%u,%u,apidl=%p,\n\tIID:%s,%p,%p)\n",
561 this,hwndOwner
,cidl
,apidl
,xclsid
,prgfInOut
,ppvOut
);
565 if(IsEqualIID(riid
, &IID_IContextMenu
))
568 pObj
= (LPUNKNOWN
)IContextMenu_Constructor(this, apidl
, cidl
);
570 else if (IsEqualIID(riid
, &IID_IDataObject
))
572 return(E_INVALIDARG
);
573 pObj
= (LPUNKNOWN
)IDataObject_Constructor (hwndOwner
, this, apidl
, cidl
);
575 else if(IsEqualIID(riid
, &IID_IExtractIcon
))
577 return(E_INVALIDARG
);
578 pidl
= ILCombine(this->pMyPidl
,apidl
[0]);
579 pObj
= (LPUNKNOWN
)IExtractIcon_Constructor( pidl
);
583 { ERR(shell
,"(%p)->E_NOINTERFACE\n",this);
584 return E_NOINTERFACE
;
587 return E_OUTOFMEMORY
;
592 /**************************************************************************
593 * IShellFolder_GetDisplayNameOf
594 * Retrieves the display name for the specified file object or subfolder
597 * LPCITEMIDLIST pidl, //[in ] complex pidl to item
598 * DWORD dwFlags, //[in ] SHGNO formatting flags
599 * LPSTRRET lpName) //[out] Returned display name
602 * if the name is in the pidl the ret value should be a STRRET_OFFSET
604 #define GET_SHGDN_FOR(dwFlags) ((DWORD)dwFlags & (DWORD)0x0000FF00)
605 #define GET_SHGDN_RELATION(dwFlags) ((DWORD)dwFlags & (DWORD)0x000000FF)
607 static HRESULT WINAPI
IShellFolder_GetDisplayNameOf( LPSHELLFOLDER
this, LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET lpName
)
608 { CHAR szText
[MAX_PATH
];
609 CHAR szTemp
[MAX_PATH
];
610 CHAR szSpecial
[MAX_PATH
];
611 CHAR szDrive
[MAX_PATH
];
612 DWORD dwVolumeSerialNumber
,dwMaximumComponetLength
,dwFileSystemFlags
;
613 LPITEMIDLIST pidlTemp
=NULL
;
614 BOOL32 bSimplePidl
=FALSE
;
616 TRACE(shell
,"(%p)->(pidl=%p,0x%08lx,%p)\n",this,pidl
,dwFlags
,lpName
);
622 /* test if simple(relative) or complex(absolute) pidl */
623 pidlTemp
= ILGetNext(pidl
);
624 if (pidlTemp
&& pidlTemp
->mkid
.cb
==0x00)
625 { bSimplePidl
= TRUE
;
626 TRACE(shell
,"-- simple pidl\n");
630 if (_ILIsDesktop( pidl
))
631 { strcpy (szText
,"Desktop");
634 { if (_ILIsMyComputer(pidl
))
635 { _ILGetItemText(pidl
, szSpecial
, MAX_PATH
);
636 pidl
= ILGetNext(pidl
);
639 if (_ILIsDrive(pidl
))
640 { _ILGetDrive( pidl
, szTemp
, MAX_PATH
);
642 if ( dwFlags
==SHGDN_NORMAL
|| dwFlags
==SHGDN_INFOLDER
) /* like "A1-dos (C:)" */
643 { GetVolumeInformation32A(szTemp
,szDrive
,MAX_PATH
,&dwVolumeSerialNumber
,&dwMaximumComponetLength
,&dwFileSystemFlags
,NULL
,0);
644 szTemp
[2]=0x00; /* overwrite '\' */
645 strcat (szDrive
," (");
646 strcat (szDrive
,szTemp
);
647 strcat (szDrive
,")");
649 else /* like "C:\" */
650 { PathAddBackslash32A (szTemp
);
651 strcpy(szDrive
,szTemp
);
657 { case SHGDN_NORMAL
: /* 0x0000 */
658 _ILGetPidlPath( pidl
, szText
, MAX_PATH
);
661 case SHGDN_INFOLDER
| SHGDN_FORPARSING
: /* 0x8001 */
662 case SHGDN_INFOLDER
: /* 0x0001 */
663 pidlTemp
= ILFindLastID(pidl
);
665 { _ILGetItemText( pidlTemp
, szText
, MAX_PATH
);
669 case SHGDN_FORPARSING
: /* 0x8000 */
671 { /* if the IShellFolder has parents, get the path from the
672 parent and add the ItemName*/
674 if (this->sMyPath
&& strlen (this->sMyPath
))
675 { if (strcmp(this->sMyPath
,"My Computer"))
676 { strcpy (szText
,this->sMyPath
);
677 PathAddBackslash32A (szText
);
680 pidlTemp
= ILFindLastID(pidl
);
682 { _ILGetItemText( pidlTemp
, szTemp
, MAX_PATH
);
684 strcat(szText
,szTemp
);
686 else /* if the pidl is absolute, get everything from the pidl*/
687 { _ILGetPidlPath( pidl
, szText
, MAX_PATH
);
691 TRACE(shell
,"--- wrong flags=%lx\n", dwFlags
);
694 if ((szText
[0]==0x00 && szDrive
[0]!=0x00)|| (bSimplePidl
&& szDrive
[0]!=0x00))
695 { strcpy(szText
,szDrive
);
697 if (szText
[0]==0x00 && szSpecial
[0]!=0x00)
698 { strcpy(szText
,szSpecial
);
702 TRACE(shell
,"-- (%p)->(%s)\n",this,szText
);
705 { return E_OUTOFMEMORY
;
707 lpName
->uType
= STRRET_CSTRA
;
708 strcpy(lpName
->u
.cStr
,szText
);
712 /**************************************************************************
713 * IShellFolder_SetNameOf
714 * Changes the name of a file object or subfolder, possibly changing its item
715 * identifier in the process.
718 * HWND hwndOwner, //[in ] Owner window for output
719 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
720 * LPCOLESTR lpszName, //[in ] the items new display name
721 * DWORD dwFlags, //[in ] SHGNO formatting flags
722 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
724 static HRESULT WINAPI
IShellFolder_SetNameOf(
727 LPCITEMIDLIST pidl
, /*simple pidl*/
730 LPITEMIDLIST
*pPidlOut
)
731 { FIXME(shell
,"(%p)->(%u,pidl=%p,%s,%lu,%p),stub!\n",
732 this,hwndOwner
,pidl
,debugstr_w(lpName
),dw
,pPidlOut
);
735 /**************************************************************************
736 * IShellFolder_GetFolderPath
737 * FIXME: drive not included
739 static BOOL32 WINAPI
IShellFolder_GetFolderPath(LPSHELLFOLDER
this, LPSTR lpszOut
, DWORD dwOutSize
)
742 TRACE(shell
,"(%p)->(%p %lu)\n",this, lpszOut
, dwOutSize
);
752 dwSize
= strlen (this->sMyPath
) +1;
753 if ( dwSize
> dwOutSize
)
755 strcpy(lpszOut
, this->sMyPath
);
757 TRACE(shell
,"-- (%p)->(return=%s)\n",this, lpszOut
);