4 * Copyright 1998 Juergen Schmied
7 * a pidl == NULL means desktop and is legal
15 #include "debugtools.h"
19 #include "undocshell.h"
20 #include "shell32_main.h"
26 DEFAULT_DEBUG_CHANNEL(pidl
);
27 DECLARE_DEBUG_CHANNEL(shell
);
29 void pdump (LPCITEMIDLIST pidl
)
33 LPITEMIDLIST pidltemp
= pidl
;
37 /* silence the sub-functions */
38 bIsShellDebug
= TRACE_ON(shell
);
39 __SET_DEBUGGING(__DBCL_TRACE
, __wine_dbch_shell
, FALSE
);
40 __SET_DEBUGGING(__DBCL_TRACE
, __wine_dbch_pidl
, FALSE
);
44 MESSAGE ("-------- pidl=NULL (Desktop)\n");
48 MESSAGE ("-------- pidl=%p\n", pidl
);
49 if (pidltemp
->mkid
.cb
)
54 LPPIDLDATA pData
= _ILGetDataPointer(pidltemp
);
55 DWORD type
= pData
->type
;
56 LPSTR szLongName
= _ILGetTextPointer(pidltemp
);
57 LPSTR szShortName
= _ILGetSTextPointer(pidltemp
);
58 char szName
[MAX_PATH
];
60 _ILSimpleGetText(pidltemp
, szName
, MAX_PATH
);
61 if( PT_FOLDER
== type
)
62 dwAttrib
= pData
->u
.folder
.uFileAttribs
;
63 else if( PT_VALUE
== type
)
64 dwAttrib
= pData
->u
.file
.uFileAttribs
;
66 MESSAGE ("-- pidl=%p size=%u type=%lx attr=0x%08lx name=%s (%s,%s)\n",
67 pidltemp
, pidltemp
->mkid
.cb
,type
,dwAttrib
,szName
,debugstr_a(szLongName
), debugstr_a(szShortName
));
69 pidltemp
= ILGetNext(pidltemp
);
71 } while (pidltemp
->mkid
.cb
);
75 MESSAGE ("empty pidl (Desktop)\n");
80 __SET_DEBUGGING(__DBCL_TRACE
, __wine_dbch_shell
, bIsShellDebug
);
81 __SET_DEBUGGING(__DBCL_TRACE
, __wine_dbch_pidl
, TRUE
);
84 #define BYTES_PRINTED 32
85 BOOL
pcheck (LPCITEMIDLIST pidl
)
86 { DWORD type
, ret
=TRUE
;
89 LPITEMIDLIST pidltemp
= pidl
;
91 bIsPidlDebug
= TRACE_ON(shell
);
92 __SET_DEBUGGING(__DBCL_TRACE
, __wine_dbch_pidl
, FALSE
);
94 if (pidltemp
&& pidltemp
->mkid
.cb
)
96 { type
= _ILGetDataPointer(pidltemp
)->type
;
117 char szTemp
[BYTES_PRINTED
*4 + 1];
121 memset(szTemp
, ' ', BYTES_PRINTED
*4 + 1);
122 for ( i
= 0; (i
<pidltemp
->mkid
.cb
) && (i
<BYTES_PRINTED
); i
++)
124 c
= ((unsigned char *)pidltemp
)[i
];
126 szTemp
[i
*3+0] = ((c
>>4)>9)? (c
>>4)+55 : (c
>>4)+48;
127 szTemp
[i
*3+1] = ((0x0F&c
)>9)? (0x0F&c
)+55 : (0x0F&c
)+48;
129 szTemp
[i
+BYTES_PRINTED
*3] = (c
>=0x20 && c
<=0x80) ? c
: '.';
131 szTemp
[BYTES_PRINTED
*4] = 0x00;
132 ERR("unknown IDLIST type size=%u type=%lx\n%s\n",pidltemp
->mkid
.cb
,type
, szTemp
);
136 pidltemp
= ILGetNext(pidltemp
);
137 } while (pidltemp
->mkid
.cb
);
139 __SET_DEBUGGING(__DBCL_TRACE
, __wine_dbch_pidl
, bIsPidlDebug
);
143 /*************************************************************************
144 * ILGetDisplayName [SHELL32.15]
146 BOOL WINAPI
ILGetDisplayName(LPCITEMIDLIST pidl
,LPSTR path
)
148 TRACE_(shell
)("pidl=%p %p semi-stub\n",pidl
,path
);
149 return SHGetPathFromIDListA(pidl
, path
);
151 /*************************************************************************
152 * ILFindLastID [SHELL32.16]
155 * observed: pidl=Desktop return=pidl
157 LPITEMIDLIST WINAPI
ILFindLastID(LPITEMIDLIST pidl
)
158 { LPITEMIDLIST pidlLast
= pidl
;
160 TRACE("(pidl=%p)\n",pidl
);
162 while (pidl
->mkid
.cb
)
165 pidl
= ILGetNext(pidl
);
169 /*************************************************************************
170 * ILRemoveLastID [SHELL32.17]
173 * when pidl=Desktop return=FALSE
175 BOOL WINAPI
ILRemoveLastID(LPCITEMIDLIST pidl
)
177 TRACE_(shell
)("pidl=%p\n",pidl
);
179 if (!pidl
|| !pidl
->mkid
.cb
)
181 ILFindLastID(pidl
)->mkid
.cb
= 0;
185 /*************************************************************************
186 * ILClone [SHELL32.18]
191 LPITEMIDLIST WINAPI
ILClone (LPCITEMIDLIST pidl
)
193 LPITEMIDLIST newpidl
;
198 len
= ILGetSize(pidl
);
199 newpidl
= (LPITEMIDLIST
)SHAlloc(len
);
201 memcpy(newpidl
,pidl
,len
);
203 TRACE("pidl=%p newpidl=%p\n",pidl
, newpidl
);
208 /*************************************************************************
209 * ILCloneFirst [SHELL32.19]
212 * duplicates the first idlist of a complex pidl
214 LPITEMIDLIST WINAPI
ILCloneFirst(LPCITEMIDLIST pidl
)
216 LPITEMIDLIST pidlNew
= NULL
;
218 TRACE("pidl=%p \n",pidl
);
224 pidlNew
= (LPITEMIDLIST
) SHAlloc (len
+2);
227 memcpy(pidlNew
,pidl
,len
+2); /* 2 -> mind a desktop pidl */
230 ILGetNext(pidlNew
)->mkid
.cb
= 0x00;
233 TRACE("-- newpidl=%p\n",pidlNew
);
238 /*************************************************************************
239 * ILLoadFromStream (SHELL32.26)
242 * the first two bytes are the len, the pidl is following then
244 HRESULT WINAPI
ILLoadFromStream (IStream
* pStream
, LPITEMIDLIST
* ppPidl
)
247 HRESULT ret
= E_FAIL
;
250 TRACE_(shell
)("%p %p\n", pStream
, ppPidl
);
257 IStream_AddRef (pStream
);
259 if (SUCCEEDED(IStream_Read(pStream
, (LPVOID
)&wLen
, 2, &dwBytesRead
)))
260 { *ppPidl
= SHAlloc (wLen
);
261 if (SUCCEEDED(IStream_Read(pStream
, *ppPidl
, wLen
, &dwBytesRead
)))
270 /* we are not yet fully compatible */
271 if (!pcheck(*ppPidl
))
277 IStream_Release (pStream
);
282 /*************************************************************************
283 * ILSaveToStream (SHELL32.27)
286 * the first two bytes are the len, the pidl is following then
288 HRESULT WINAPI
ILSaveToStream (IStream
* pStream
, LPCITEMIDLIST pPidl
)
292 HRESULT ret
= E_FAIL
;
294 TRACE_(shell
)("%p %p\n", pStream
, pPidl
);
296 IStream_AddRef (pStream
);
299 while (pidl
->mkid
.cb
)
301 wLen
+= sizeof(WORD
) + pidl
->mkid
.cb
;
302 pidl
= ILGetNext(pidl
);
305 if (SUCCEEDED(IStream_Write(pStream
, (LPVOID
)&wLen
, 2, NULL
)))
307 if (SUCCEEDED(IStream_Write(pStream
, pPidl
, wLen
, NULL
)))
313 IStream_Release (pStream
);
318 /*************************************************************************
319 * SHILCreateFromPath [SHELL32.28]
322 * wraper for IShellFolder::ParseDisplayName()
324 HRESULT WINAPI
SHILCreateFromPathA (LPCSTR path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
326 WCHAR lpszDisplayName
[MAX_PATH
];
328 HRESULT ret
= E_FAIL
;
330 TRACE_(shell
)("%s %p 0x%08lx\n",path
,ppidl
,attributes
?*attributes
:0);
332 if (!MultiByteToWideChar( CP_ACP
, 0, path
, -1, lpszDisplayName
, MAX_PATH
))
333 lpszDisplayName
[MAX_PATH
-1] = 0;
335 if (SUCCEEDED (SHGetDesktopFolder(&sf
)))
337 ret
= IShellFolder_ParseDisplayName(sf
,0, NULL
,lpszDisplayName
,&pchEaten
,ppidl
,attributes
);
338 IShellFolder_Release(sf
);
342 HRESULT WINAPI
SHILCreateFromPathW (LPCWSTR path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
345 HRESULT ret
= E_FAIL
;
347 TRACE_(shell
)("%s %p 0x%08lx\n",debugstr_w(path
),ppidl
,attributes
?*attributes
:0);
349 if (SUCCEEDED (SHGetDesktopFolder(&sf
)))
351 ret
= IShellFolder_ParseDisplayName(sf
,0, NULL
, (LPWSTR
) path
, &pchEaten
, ppidl
, attributes
);
352 IShellFolder_Release(sf
);
356 HRESULT WINAPI
SHILCreateFromPathAW (LPCVOID path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
358 if ( SHELL_OsIsUnicode())
359 return SHILCreateFromPathW (path
, ppidl
, attributes
);
360 return SHILCreateFromPathA (path
, ppidl
, attributes
);
363 /*************************************************************************
364 * SHCloneSpecialIDList [SHELL32.89]
368 * nFolder [in] CSIDL_xxxxx ??
373 * exported by ordinal
375 LPITEMIDLIST WINAPI
SHCloneSpecialIDList(HWND hwndOwner
,DWORD nFolder
,DWORD x3
)
376 { LPITEMIDLIST ppidl
;
377 WARN_(shell
)("(hwnd=0x%x,csidl=0x%lx,0x%lx):semi-stub.\n",
378 hwndOwner
,nFolder
,x3
);
380 SHGetSpecialFolderLocation(hwndOwner
, nFolder
, &ppidl
);
385 /*************************************************************************
386 * ILGlobalClone [SHELL32.20]
389 LPITEMIDLIST WINAPI
ILGlobalClone(LPCITEMIDLIST pidl
)
391 LPITEMIDLIST newpidl
;
396 len
= ILGetSize(pidl
);
397 newpidl
= (LPITEMIDLIST
)pCOMCTL32_Alloc(len
);
399 memcpy(newpidl
,pidl
,len
);
401 TRACE("pidl=%p newpidl=%p\n",pidl
, newpidl
);
407 /*************************************************************************
408 * ILIsEqual [SHELL32.21]
411 BOOL WINAPI
ILIsEqual(LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
413 char szData1
[MAX_PATH
];
414 char szData2
[MAX_PATH
];
416 LPITEMIDLIST pidltemp1
= pidl1
;
417 LPITEMIDLIST pidltemp2
= pidl2
;
419 TRACE("pidl1=%p pidl2=%p\n",pidl1
, pidl2
);
421 /* explorer reads from registry directly (StreamMRU),
422 so we can only check here */
423 if ((!pcheck (pidl1
)) || (!pcheck (pidl2
))) return FALSE
;
428 if ( (!pidl1
) || (!pidl2
) ) return FALSE
;
430 while (pidltemp1
->mkid
.cb
&& pidltemp2
->mkid
.cb
)
432 _ILSimpleGetText(pidltemp1
, szData1
, MAX_PATH
);
433 _ILSimpleGetText(pidltemp2
, szData2
, MAX_PATH
);
435 if (strcasecmp ( szData1
, szData2
)!=0 )
438 pidltemp1
= ILGetNext(pidltemp1
);
439 pidltemp2
= ILGetNext(pidltemp2
);
442 if (!pidltemp1
->mkid
.cb
&& !pidltemp2
->mkid
.cb
)
449 /*************************************************************************
450 * ILIsParent [SHELL32.23]
452 * parent=a/b child=a/b/c -> true, c is in folder a/b
453 * child=a/b/c/d -> false if bImmediate is true, d is not in folder a/b
454 * child=a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b
456 BOOL WINAPI
ILIsParent( LPCITEMIDLIST pidlParent
, LPCITEMIDLIST pidlChild
, BOOL bImmediate
)
458 char szData1
[MAX_PATH
];
459 char szData2
[MAX_PATH
];
461 LPITEMIDLIST pParent
= pidlParent
;
462 LPITEMIDLIST pChild
= pidlChild
;
464 TRACE("%p %p %x\n", pidlParent
, pidlChild
, bImmediate
);
466 while (pParent
->mkid
.cb
&& pChild
->mkid
.cb
)
468 _ILSimpleGetText(pParent
, szData1
, MAX_PATH
);
469 _ILSimpleGetText(pChild
, szData2
, MAX_PATH
);
471 if (strcasecmp ( szData1
, szData2
)!=0 )
474 pParent
= ILGetNext(pParent
);
475 pChild
= ILGetNext(pChild
);
478 if ( pParent
->mkid
.cb
|| ! pChild
->mkid
.cb
) /* child shorter or has equal length to parent */
481 if ( ILGetNext(pChild
)->mkid
.cb
&& bImmediate
) /* not immediate descent */
487 /*************************************************************************
488 * ILFindChild [SHELL32.24]
491 * Compares elements from pidl1 and pidl2.
493 * pidl1 is desktop pidl2
494 * pidl1 shorter pidl2 pointer to first different element of pidl2
495 * if there was at least one equal element
496 * pidl2 shorter pidl1 0
497 * pidl2 equal pidl1 pointer to last 0x00-element of pidl2
499 LPITEMIDLIST WINAPI
ILFindChild(LPCITEMIDLIST pidl1
,LPCITEMIDLIST pidl2
)
501 char szData1
[MAX_PATH
];
502 char szData2
[MAX_PATH
];
504 LPITEMIDLIST pidltemp1
= pidl1
;
505 LPITEMIDLIST pidltemp2
= pidl2
;
506 LPITEMIDLIST ret
=NULL
;
508 TRACE("pidl1=%p pidl2=%p\n",pidl1
, pidl2
);
510 /* explorer reads from registry directly (StreamMRU),
511 so we can only check here */
512 if ((!pcheck (pidl1
)) || (!pcheck (pidl2
)))
518 if ( _ILIsDesktop(pidl1
) )
524 while (pidltemp1
->mkid
.cb
&& pidltemp2
->mkid
.cb
)
526 _ILSimpleGetText(pidltemp1
, szData1
, MAX_PATH
);
527 _ILSimpleGetText(pidltemp2
, szData2
, MAX_PATH
);
529 if (strcasecmp(szData1
,szData2
))
532 pidltemp1
= ILGetNext(pidltemp1
);
533 pidltemp2
= ILGetNext(pidltemp2
);
537 if (pidltemp1
->mkid
.cb
)
539 ret
= NULL
; /* elements of pidl1 left*/
542 TRACE_(shell
)("--- %p\n", ret
);
543 return ret
; /* pidl 1 is shorter */
546 /*************************************************************************
547 * ILCombine [SHELL32.25]
550 * Concatenates two complex idlists.
551 * The pidl is the first one, pidlsub the next one
552 * Does not destroy the passed in idlists!
554 LPITEMIDLIST WINAPI
ILCombine(LPCITEMIDLIST pidl1
,LPCITEMIDLIST pidl2
)
557 LPITEMIDLIST pidlNew
;
559 TRACE("pidl=%p pidl=%p\n",pidl1
,pidl2
);
561 if(!pidl1
&& !pidl2
) return NULL
;
568 pidlNew
= ILClone(pidl2
);
574 pidlNew
= ILClone(pidl1
);
578 len1
= ILGetSize(pidl1
)-2;
579 len2
= ILGetSize(pidl2
);
580 pidlNew
= SHAlloc(len1
+len2
);
584 memcpy(pidlNew
,pidl1
,len1
);
585 memcpy(((BYTE
*)pidlNew
)+len1
,pidl2
,len2
);
588 /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/
591 /*************************************************************************
592 * SHGetRealIDL [SHELL32.98]
596 LPITEMIDLIST WINAPI
SHGetRealIDL(LPSHELLFOLDER lpsf
, LPITEMIDLIST pidl
, DWORD z
)
598 FIXME("sf=%p pidl=%p 0x%04lx\n",lpsf
,pidl
,z
);
604 /*************************************************************************
605 * SHLogILFromFSIL [SHELL32.95]
608 * pild = CSIDL_DESKTOP ret = 0
609 * pild = CSIDL_DRIVES ret = 0
611 LPITEMIDLIST WINAPI
SHLogILFromFSIL(LPITEMIDLIST pidl
)
613 FIXME("(pidl=%p)\n",pidl
);
620 /*************************************************************************
621 * ILGetSize [SHELL32.152]
622 * gets the byte size of an idlist including zero terminator (pidl)
631 * exported by ordinal
633 DWORD WINAPI
ILGetSize(LPITEMIDLIST pidl
)
635 LPSHITEMID si
= &(pidl
->mkid
);
641 si
= (LPSHITEMID
)(((LPBYTE
)si
)+si
->cb
);
645 TRACE("pidl=%p size=%lu\n",pidl
, len
);
649 /*************************************************************************
650 * ILGetNext [SHELL32.153]
651 * gets the next simple pidl of a complex pidl
653 * observed return values:
656 * simple pidl -> pointer to 0x0000 element
659 LPITEMIDLIST WINAPI
ILGetNext(LPITEMIDLIST pidl
)
663 TRACE("(pidl=%p)\n",pidl
);
670 pidl
= (LPITEMIDLIST
) (((LPBYTE
)pidl
)+len
);
676 /*************************************************************************
677 * ILAppend [SHELL32.154]
680 * Adds the single item to the idlist indicated by pidl.
681 * if bEnd is 0, adds the item to the front of the list,
682 * otherwise adds the item to the end. (???)
683 * Destroys the passed in idlist! (???)
685 LPITEMIDLIST WINAPI
ILAppend(LPITEMIDLIST pidl
,LPCITEMIDLIST item
,BOOL bEnd
)
689 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl
,item
,bEnd
);
694 if (_ILIsDesktop(pidl
))
696 idlRet
= ILClone(item
);
704 idlRet
=ILCombine(pidl
,item
);
708 idlRet
=ILCombine(item
,pidl
);
714 /*************************************************************************
715 * ILFree [SHELL32.155]
718 * free_check_ptr - frees memory (if not NULL)
719 * allocated by SHMalloc allocator
720 * exported by ordinal
722 DWORD WINAPI
ILFree(LPITEMIDLIST pidl
)
724 TRACE("(pidl=0x%08lx)\n",(DWORD
)pidl
);
726 if(!pidl
) return FALSE
;
730 /*************************************************************************
731 * ILGlobalFree [SHELL32.156]
734 void WINAPI
ILGlobalFree( LPCITEMIDLIST pidl
)
739 pCOMCTL32_Free(pidl
);
741 /*************************************************************************
742 * ILCreateFromPath [SHELL32.157]
745 LPITEMIDLIST WINAPI
ILCreateFromPathA (LPCSTR path
)
747 LPITEMIDLIST pidlnew
;
748 DWORD attributes
= 0;
750 TRACE_(shell
)("%s\n",path
);
752 if (SUCCEEDED (SHILCreateFromPathA (path
, &pidlnew
, &attributes
)))
756 LPITEMIDLIST WINAPI
ILCreateFromPathW (LPCWSTR path
)
758 LPITEMIDLIST pidlnew
;
759 DWORD attributes
= 0;
761 TRACE_(shell
)("%s\n",debugstr_w(path
));
763 if (SUCCEEDED (SHILCreateFromPathW (path
, &pidlnew
, &attributes
)))
767 LPITEMIDLIST WINAPI
ILCreateFromPathAW (LPCVOID path
)
769 if ( SHELL_OsIsUnicode())
770 return ILCreateFromPathW (path
);
771 return ILCreateFromPathA (path
);
773 /*************************************************************************
774 * SHSimpleIDListFromPath [SHELL32.162]
776 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathA (LPCSTR lpszPath
)
778 LPITEMIDLIST pidl
=NULL
;
780 WIN32_FIND_DATAA stffile
;
782 TRACE("path=%s\n", lpszPath
);
784 if (!lpszPath
) return NULL
;
786 hFile
= FindFirstFileA(lpszPath
, &stffile
);
788 if ( hFile
!= INVALID_HANDLE_VALUE
)
790 if (stffile
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
792 pidl
= _ILCreateFolder (&stffile
);
796 pidl
= _ILCreateValue (&stffile
);
802 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathW (LPCWSTR lpszPath
)
804 char lpszTemp
[MAX_PATH
];
805 TRACE("path=%s\n",debugstr_w(lpszPath
));
807 if (!WideCharToMultiByte( CP_ACP
, 0, lpszPath
, -1, lpszTemp
, sizeof(lpszTemp
), NULL
, NULL
))
808 lpszTemp
[sizeof(lpszTemp
)-1] = 0;
810 return SHSimpleIDListFromPathA (lpszTemp
);
813 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathAW (LPCVOID lpszPath
)
815 if ( SHELL_OsIsUnicode())
816 return SHSimpleIDListFromPathW (lpszPath
);
817 return SHSimpleIDListFromPathA (lpszPath
);
820 /*************************************************************************
821 * SHGetSpecialFolderLocation [SHELL32.@]
823 * gets the folder locations from the registry and creates a pidl
824 * creates missing reg keys and directorys
828 * nFolder [I] CSIDL_xxxxx
829 * ppidl [O] PIDL of a special folder
832 HRESULT WINAPI
SHGetSpecialFolderLocation(
835 LPITEMIDLIST
* ppidl
)
837 CHAR szPath
[MAX_PATH
];
838 HRESULT hr
= E_INVALIDARG
;
840 TRACE_(shell
)("(%04x,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
848 *ppidl
= _ILCreateDesktop();
852 *ppidl
= _ILCreateMyComputer();
856 *ppidl
= _ILCreateNetwork ();
860 *ppidl
= _ILCreateControl ();
864 *ppidl
= _ILCreatePrinter ();
867 case CSIDL_BITBUCKET
:
868 *ppidl
= _ILCreateBitBucket ();
872 if (SHGetSpecialFolderPathA(hwndOwner
, szPath
, nFolder
, TRUE
))
875 TRACE_(shell
)("Value=%s\n",szPath
);
876 hr
= SHILCreateFromPathA(szPath
, ppidl
, &attributes
);
879 if(*ppidl
) hr
= NOERROR
;
882 TRACE_(shell
)("-- (new pidl %p)\n",*ppidl
);
886 /*************************************************************************
887 * SHGetFolderLocation [SHELL32.@]
890 * the pidl can be a simple one. since we cant get the path out of the pidl
891 * we have to take all data from the pidl
893 HRESULT WINAPI
SHGetFolderLocation(
900 FIXME("0x%04x 0x%08x 0x%08x 0x%08lx %p\n",
901 hwnd
, csidl
, hToken
, dwFlags
, ppidl
);
902 return SHGetSpecialFolderLocation(hwnd
, csidl
, ppidl
);
905 /*************************************************************************
906 * SHGetDataFromIDListA [SHELL32.247]
909 * the pidl can be a simple one. since we cant get the path out of the pidl
910 * we have to take all data from the pidl
912 HRESULT WINAPI
SHGetDataFromIDListA(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, int nFormat
, LPVOID dest
, int len
)
914 TRACE_(shell
)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf
,pidl
,nFormat
,dest
,len
);
917 if (!psf
|| !dest
) return E_INVALIDARG
;
921 case SHGDFIL_FINDDATA
:
923 WIN32_FIND_DATAA
* pfd
= dest
;
925 if ( len
< sizeof (WIN32_FIND_DATAA
)) return E_INVALIDARG
;
927 ZeroMemory(pfd
, sizeof (WIN32_FIND_DATAA
));
928 _ILGetFileDateTime( pidl
, &(pfd
->ftLastWriteTime
));
929 pfd
->dwFileAttributes
= _ILGetFileAttributes(pidl
, NULL
, 0);
930 pfd
->nFileSizeLow
= _ILGetFileSize ( pidl
, NULL
, 0);
931 lstrcpynA(pfd
->cFileName
,_ILGetTextPointer(pidl
), MAX_PATH
);
932 lstrcpynA(pfd
->cAlternateFileName
,_ILGetSTextPointer(pidl
), 14);
936 case SHGDFIL_NETRESOURCE
:
937 case SHGDFIL_DESCRIPTIONID
:
938 FIXME_(shell
)("SHGDFIL %i stub\n", nFormat
);
942 ERR_(shell
)("Unknown SHGDFIL %i, please report\n", nFormat
);
947 /*************************************************************************
948 * SHGetDataFromIDListW [SHELL32.248]
951 HRESULT WINAPI
SHGetDataFromIDListW(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, int nFormat
, LPVOID dest
, int len
)
953 TRACE_(shell
)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf
,pidl
,nFormat
,dest
,len
);
957 if (! psf
|| !dest
) return E_INVALIDARG
;
961 case SHGDFIL_FINDDATA
:
963 WIN32_FIND_DATAW
* pfd
= dest
;
965 if ( len
< sizeof (WIN32_FIND_DATAW
)) return E_INVALIDARG
;
967 ZeroMemory(pfd
, sizeof (WIN32_FIND_DATAA
));
968 _ILGetFileDateTime( pidl
, &(pfd
->ftLastWriteTime
));
969 pfd
->dwFileAttributes
= _ILGetFileAttributes(pidl
, NULL
, 0);
970 pfd
->nFileSizeLow
= _ILGetFileSize ( pidl
, NULL
, 0);
971 if (!MultiByteToWideChar( CP_ACP
, 0, _ILGetTextPointer(pidl
), -1,
972 pfd
->cFileName
, MAX_PATH
))
973 pfd
->cFileName
[MAX_PATH
-1] = 0;
974 if (!MultiByteToWideChar( CP_ACP
, 0, _ILGetSTextPointer(pidl
), -1,
975 pfd
->cAlternateFileName
, 14 ))
976 pfd
->cFileName
[13] = 0;
979 case SHGDFIL_NETRESOURCE
:
980 case SHGDFIL_DESCRIPTIONID
:
981 FIXME_(shell
)("SHGDFIL %i stub\n", nFormat
);
985 ERR_(shell
)("Unknown SHGDFIL %i, please report\n", nFormat
);
991 /*************************************************************************
992 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
999 * path from a passed PIDL.
1002 * NULL returns FALSE
1003 * desktop pidl gives path to desktopdirectory back
1004 * special pidls returning FALSE
1007 * fnGetDisplayNameOf can return different types of OLEString
1009 BOOL WINAPI
SHGetPathFromIDListA (LPCITEMIDLIST pidl
,LPSTR pszPath
)
1011 LPSHELLFOLDER shellfolder
;
1013 TRACE_(shell
)("(pidl=%p,%p)\n",pidl
,pszPath
);
1015 if (!pidl
) return FALSE
;
1019 if(_ILIsDesktop(pidl
))
1021 SHGetSpecialFolderPathA(0, pszPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
1023 else if (_ILIsSpecialFolder(ILFindLastID(pidl
)))
1025 /* we are somewhere in a special folder */
1030 if (SHGetDesktopFolder(&shellfolder
)==S_OK
)
1032 IShellFolder_GetDisplayNameOf(shellfolder
,pidl
,SHGDN_FORPARSING
,&str
);
1033 StrRetToStrNA (pszPath
, MAX_PATH
, &str
, pidl
);
1034 IShellFolder_Release(shellfolder
);
1037 TRACE_(shell
)("-- (%s)\n",pszPath
);
1041 /*************************************************************************
1042 * SHGetPathFromIDListW [SHELL32.@]
1044 BOOL WINAPI
SHGetPathFromIDListW (LPCITEMIDLIST pidl
,LPWSTR pszPath
)
1045 { char sTemp
[MAX_PATH
];
1047 TRACE_(shell
)("(pidl=%p)\n", pidl
);
1049 SHGetPathFromIDListA (pidl
, sTemp
);
1050 MultiByteToWideChar( CP_ACP
, 0, sTemp
, -1, pszPath
, MAX_PATH
);
1052 TRACE_(shell
)("-- (%s)\n",debugstr_w(pszPath
));
1057 /*************************************************************************
1058 * SHBindToParent [shell version 5.0]
1060 HRESULT WINAPI
SHBindToParent(LPCITEMIDLIST pidl
, REFIID riid
, LPVOID
*ppv
, LPCITEMIDLIST
*ppidlLast
)
1063 LPITEMIDLIST pidlChild
, pidlParent
;
1066 TRACE_(shell
)("pidl=%p\n", pidl
);
1070 if (ppidlLast
) *ppidlLast
= NULL
;
1072 if (_ILIsPidlSimple(pidl
))
1074 /* we are on desktop level */
1076 *ppidlLast
= ILClone(pidl
);
1077 hr
= SHGetDesktopFolder((IShellFolder
**)ppv
);
1081 pidlChild
= ILClone(ILFindLastID(pidl
));
1082 pidlParent
= ILClone(pidl
);
1083 ILRemoveLastID(pidlParent
);
1085 hr
= SHGetDesktopFolder(&psf
);
1088 hr
= IShellFolder_BindToObject(psf
, pidlParent
, NULL
, riid
, ppv
);
1090 if (SUCCEEDED(hr
) && ppidlLast
)
1091 *ppidlLast
= pidlChild
;
1095 SHFree (pidlParent
);
1096 if (psf
) IShellFolder_Release(psf
);
1100 TRACE_(shell
)("-- psf=%p pidl=%p ret=0x%08lx\n", *ppv
, (ppidlLast
)?*ppidlLast
:NULL
, hr
);
1104 /*************************************************************************
1105 * SHGetPathFromIDList [SHELL32.@][NT 4.0: SHELL32.219]
1107 BOOL WINAPI
SHGetPathFromIDListAW(LPCITEMIDLIST pidl
,LPVOID pszPath
)
1109 TRACE_(shell
)("(pidl=%p,%p)\n",pidl
,pszPath
);
1111 if (SHELL_OsIsUnicode())
1112 return SHGetPathFromIDListW(pidl
,pszPath
);
1113 return SHGetPathFromIDListA(pidl
,pszPath
);
1116 /**************************************************************************
1118 * internal functions
1120 * ### 1. section creating pidls ###
1122 *************************************************************************
1123 * _ILCreateDesktop()
1124 * _ILCreateIExplore()
1125 * _ILCreateMyComputer()
1130 LPITEMIDLIST
_ILCreateDesktop()
1132 return _ILCreate(PT_DESKTOP
, NULL
, 0);
1135 LPITEMIDLIST
_ILCreateMyComputer()
1137 return _ILCreate(PT_MYCOMP
, &CLSID_MyComputer
, sizeof(GUID
));
1140 LPITEMIDLIST
_ILCreateIExplore()
1142 return _ILCreate(PT_MYCOMP
, &CLSID_Internet
, sizeof(GUID
));
1145 LPITEMIDLIST
_ILCreateControl()
1147 return _ILCreate(PT_SPECIAL
, &CLSID_ControlPanel
, sizeof(GUID
));
1150 LPITEMIDLIST
_ILCreatePrinter()
1152 return _ILCreate(PT_SPECIAL
, &CLSID_Printers
, sizeof(GUID
));
1155 LPITEMIDLIST
_ILCreateNetwork()
1157 return _ILCreate(PT_MYCOMP
, &CLSID_NetworkPlaces
, sizeof(GUID
));
1160 LPITEMIDLIST
_ILCreateBitBucket()
1162 return _ILCreate(PT_MYCOMP
, &CLSID_RecycleBin
, sizeof(GUID
));
1165 LPITEMIDLIST
_ILCreateDrive( LPCSTR lpszNew
)
1167 lstrcpynA (sTemp
,lpszNew
,4);
1170 TRACE("(%s)\n",sTemp
);
1171 return _ILCreate(PT_DRIVE
,(LPVOID
)&sTemp
[0],4);
1174 LPITEMIDLIST
_ILCreateFolder( WIN32_FIND_DATAA
* stffile
)
1176 char buff
[MAX_PATH
+ 14 +1]; /* see WIN32_FIND_DATA */
1177 char * pbuff
= buff
;
1181 TRACE("(%s, %s)\n",stffile
->cAlternateFileName
, stffile
->cFileName
);
1183 /* prepare buffer with both names */
1184 len
= strlen (stffile
->cFileName
) + 1;
1185 memcpy (pbuff
, stffile
->cFileName
, len
);
1188 if (stffile
->cAlternateFileName
)
1190 len1
= strlen (stffile
->cAlternateFileName
)+1;
1191 memcpy (pbuff
, stffile
->cAlternateFileName
, len1
);
1199 pidl
= _ILCreate(PT_FOLDER
, (LPVOID
)buff
, len
+ len1
);
1201 /* set attributes */
1205 pData
= _ILGetDataPointer(pidl
);
1206 FileTimeToDosDateTime(&(stffile
->ftLastWriteTime
),&pData
->u
.folder
.uFileDate
,&pData
->u
.folder
.uFileTime
);
1207 pData
->u
.folder
.dwFileSize
= stffile
->nFileSizeLow
;
1208 pData
->u
.folder
.uFileAttribs
=stffile
->dwFileAttributes
;
1214 LPITEMIDLIST
_ILCreateValue(WIN32_FIND_DATAA
* stffile
)
1216 char buff
[MAX_PATH
+ 14 +1]; /* see WIN32_FIND_DATA */
1217 char * pbuff
= buff
;
1221 TRACE("(%s, %s)\n",stffile
->cAlternateFileName
, stffile
->cFileName
);
1223 /* prepare buffer with both names */
1224 len
= strlen (stffile
->cFileName
) + 1;
1225 memcpy (pbuff
, stffile
->cFileName
, len
);
1228 if (stffile
->cAlternateFileName
)
1230 len1
= strlen (stffile
->cAlternateFileName
)+1;
1231 memcpy (pbuff
, stffile
->cAlternateFileName
, len1
);
1239 pidl
= _ILCreate(PT_VALUE
, (LPVOID
)buff
, len
+ len1
);
1241 /* set attributes */
1245 pData
= _ILGetDataPointer(pidl
);
1246 FileTimeToDosDateTime(&(stffile
->ftLastWriteTime
),&pData
->u
.folder
.uFileDate
,&pData
->u
.folder
.uFileTime
);
1247 pData
->u
.folder
.dwFileSize
= stffile
->nFileSizeLow
;
1248 pData
->u
.folder
.uFileAttribs
=stffile
->dwFileAttributes
;
1254 LPITEMIDLIST
_ILCreateSpecial(LPCSTR szGUID
)
1259 if (!MultiByteToWideChar( CP_ACP
, 0, szGUID
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
1261 CLSIDFromString( buffer
, &iid
);
1262 return _ILCreate(PT_MYCOMP
, &iid
, sizeof(IID
));
1265 /**************************************************************************
1267 * Creates a new PIDL
1268 * type = PT_DESKTOP | PT_DRIVE | PT_FOLDER | PT_VALUE
1270 * uInSize = size of data (raw)
1273 LPITEMIDLIST
_ILCreate(PIDLTYPE type
, LPCVOID pIn
, UINT uInSize
)
1275 LPITEMIDLIST pidlOut
= NULL
, pidlTemp
= NULL
;
1280 TRACE("(0x%02x %p %i)\n",type
,pIn
,uInSize
);
1289 uSize
= 2 + 2 + sizeof(GUID
);
1296 uSize
= 2 + 12 + uInSize
;
1299 FIXME("can't create type: 0x%08x\n",type
);
1303 if(!(pidlOut
= SHAlloc(uSize
+ 2))) return NULL
;
1304 ZeroMemory(pidlOut
, uSize
+ 2);
1305 pidlOut
->mkid
.cb
= uSize
;
1310 TRACE("- create Desktop\n");
1315 pData
=_ILGetDataPointer(pidlOut
);
1317 memcpy(&(pData
->u
.mycomp
.guid
), pIn
, uInSize
);
1318 TRACE("- create GUID-pidl\n");
1322 pData
=_ILGetDataPointer(pidlOut
);
1324 pszDest
= _ILGetTextPointer(pidlOut
);
1325 memcpy(pszDest
, pIn
, uInSize
);
1326 TRACE("- create Drive: %s\n",debugstr_a(pszDest
));
1331 pData
=_ILGetDataPointer(pidlOut
);
1333 pszDest
= _ILGetTextPointer(pidlOut
);
1334 memcpy(pszDest
, pIn
, uInSize
);
1335 TRACE("- create Value: %s\n",debugstr_a(pszDest
));
1339 pidlTemp
= ILGetNext(pidlOut
);
1341 pidlTemp
->mkid
.cb
= 0x00;
1343 TRACE("-- (pidl=%p, size=%u)\n", pidlOut
, uSize
);
1347 /**************************************************************************
1350 * Gets the text for the drive eg. 'c:\'
1355 DWORD
_ILGetDrive(LPCITEMIDLIST pidl
,LPSTR pOut
, UINT uSize
)
1356 { TRACE("(%p,%p,%u)\n",pidl
,pOut
,uSize
);
1358 if(_ILIsMyComputer(pidl
))
1359 pidl
= ILGetNext(pidl
);
1361 if (pidl
&& _ILIsDrive(pidl
))
1362 return _ILSimpleGetText(pidl
, pOut
, uSize
);
1367 /**************************************************************************
1369 * ### 2. section testing pidls ###
1371 **************************************************************************
1374 * _ILIsSpecialFolder()
1380 BOOL
_ILIsDesktop(LPCITEMIDLIST pidl
)
1381 { TRACE("(%p)\n",pidl
);
1382 return ( !pidl
|| (pidl
&& pidl
->mkid
.cb
== 0x00) );
1385 BOOL
_ILIsMyComputer(LPCITEMIDLIST pidl
)
1387 REFIID iid
= _ILGetGUIDPointer(pidl
);
1389 TRACE("(%p)\n",pidl
);
1392 return IsEqualIID(iid
, &CLSID_MyComputer
);
1396 BOOL
_ILIsSpecialFolder (LPCITEMIDLIST pidl
)
1398 LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1399 TRACE("(%p)\n",pidl
);
1400 return (pidl
&& ( (lpPData
&& (PT_MYCOMP
== lpPData
->type
|| PT_SPECIAL
== lpPData
->type
)) ||
1401 (pidl
&& pidl
->mkid
.cb
== 0x00)
1405 BOOL
_ILIsDrive(LPCITEMIDLIST pidl
)
1406 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1407 TRACE("(%p)\n",pidl
);
1408 return (pidl
&& lpPData
&& (PT_DRIVE
== lpPData
->type
||
1409 PT_DRIVE1
== lpPData
->type
||
1410 PT_DRIVE2
== lpPData
->type
||
1411 PT_DRIVE3
== lpPData
->type
));
1414 BOOL
_ILIsFolder(LPCITEMIDLIST pidl
)
1415 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1416 TRACE("(%p)\n",pidl
);
1417 return (pidl
&& lpPData
&& (PT_FOLDER
== lpPData
->type
|| PT_FOLDER1
== lpPData
->type
));
1420 BOOL
_ILIsValue(LPCITEMIDLIST pidl
)
1421 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1422 TRACE("(%p)\n",pidl
);
1423 return (pidl
&& lpPData
&& PT_VALUE
== lpPData
->type
);
1426 /**************************************************************************
1429 BOOL
_ILIsPidlSimple ( LPCITEMIDLIST pidl
)
1433 if(! _ILIsDesktop(pidl
)) /* pidl=NULL or mkid.cb=0 */
1435 WORD len
= pidl
->mkid
.cb
;
1436 LPCITEMIDLIST pidlnext
= (LPCITEMIDLIST
) (((LPBYTE
)pidl
) + len
);
1437 if (pidlnext
->mkid
.cb
)
1441 TRACE("%s\n", ret
? "Yes" : "No");
1445 /**************************************************************************
1447 * ### 3. section getting values from pidls ###
1450 /**************************************************************************
1453 * gets the text for the first item in the pidl (eg. simple pidl)
1455 * returns the length of the string
1457 DWORD
_ILSimpleGetText (LPCITEMIDLIST pidl
, LPSTR szOut
, UINT uOutSize
)
1462 char szTemp
[MAX_PATH
];
1464 TRACE("(%p %p %x)\n",pidl
,szOut
,uOutSize
);
1466 if (!pidl
) return 0;
1471 if (_ILIsDesktop(pidl
))
1474 if (HCR_GetClassName(&CLSID_ShellDesktop
, szTemp
, MAX_PATH
))
1477 lstrcpynA(szOut
, szTemp
, uOutSize
);
1479 dwReturn
= strlen (szTemp
);
1482 else if (( szSrc
= _ILGetTextPointer(pidl
) ))
1486 lstrcpynA(szOut
, szSrc
, uOutSize
);
1488 dwReturn
= strlen(szSrc
);
1490 else if (( riid
= _ILGetGUIDPointer(pidl
) ))
1492 /* special folder */
1493 if ( HCR_GetClassName(riid
, szTemp
, MAX_PATH
) )
1496 lstrcpynA(szOut
, szTemp
, uOutSize
);
1498 dwReturn
= strlen (szTemp
);
1503 ERR("-- no text\n");
1506 TRACE("-- (%p=%s 0x%08lx)\n",szOut
,(char*)szOut
,dwReturn
);
1510 /**************************************************************************
1512 * ### 4. getting pointers to parts of pidls ###
1514 **************************************************************************
1515 * _ILGetDataPointer()
1517 LPPIDLDATA
_ILGetDataPointer(LPITEMIDLIST pidl
)
1519 if(pidl
&& pidl
->mkid
.cb
!= 0x00)
1520 return (LPPIDLDATA
) &(pidl
->mkid
.abID
);
1524 /**************************************************************************
1525 * _ILGetTextPointer()
1526 * gets a pointer to the long filename string stored in the pidl
1528 LPSTR
_ILGetTextPointer(LPCITEMIDLIST pidl
)
1529 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1531 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1535 switch (pdata
->type
)
1545 return (LPSTR
)&(pdata
->u
.drive
.szDriveName
);
1552 return (LPSTR
)&(pdata
->u
.file
.szNames
);
1558 return (LPSTR
)&(pdata
->u
.network
.szNames
);
1564 /**************************************************************************
1565 * _ILGetSTextPointer()
1566 * gets a pointer to the short filename string stored in the pidl
1568 LPSTR
_ILGetSTextPointer(LPCITEMIDLIST pidl
)
1569 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1571 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1575 switch (pdata
->type
)
1581 return (LPSTR
)(pdata
->u
.file
.szNames
+ strlen (pdata
->u
.file
.szNames
) + 1);
1584 return (LPSTR
)(pdata
->u
.network
.szNames
+ strlen (pdata
->u
.network
.szNames
) + 1);
1590 /**************************************************************************
1591 * _ILGetGUIDPointer()
1593 * returns reference to guid stored in some pidls
1595 REFIID
_ILGetGUIDPointer(LPCITEMIDLIST pidl
)
1597 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1601 switch (pdata
->type
)
1605 return (REFIID
) &(pdata
->u
.mycomp
.guid
);
1611 /*************************************************************************
1612 * _ILGetFileDateTime
1614 * Given the ItemIdList, get the FileTime
1617 * pidl [I] The ItemIDList
1618 * pFt [I] the resulted FILETIME of the file
1621 * True if Successful
1626 BOOL
_ILGetFileDateTime(LPCITEMIDLIST pidl
, FILETIME
*pFt
)
1628 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1630 if(! pdata
) return FALSE
;
1632 switch (pdata
->type
)
1635 DosDateTimeToFileTime(pdata
->u
.folder
.uFileDate
, pdata
->u
.folder
.uFileTime
, pFt
);
1638 DosDateTimeToFileTime(pdata
->u
.file
.uFileDate
, pdata
->u
.file
.uFileTime
, pFt
);
1646 BOOL
_ILGetFileDate (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1651 if (! _ILGetFileDateTime( pidl
, &ft
)) return FALSE
;
1653 FileTimeToLocalFileTime(&ft
, &lft
);
1654 FileTimeToSystemTime (&lft
, &time
);
1655 return GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&time
, NULL
, pOut
, uOutSize
);
1658 /*************************************************************************
1661 * Given the ItemIdList, get the FileSize
1664 * pidl [I] The ItemIDList
1665 * pOut [I] The buffer to save the result
1666 * uOutsize [I] The size of the buffer
1672 * pOut can be null when no string is needed
1675 DWORD
_ILGetFileSize (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1677 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1680 if(! pdata
) return 0;
1682 switch (pdata
->type
)
1685 dwSize
= pdata
->u
.file
.dwFileSize
;
1686 if (pOut
) StrFormatByteSizeA(dwSize
, pOut
, uOutSize
);
1689 if (pOut
) *pOut
= 0x00;
1693 BOOL
_ILGetExtension (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1695 char szTemp
[MAX_PATH
];
1696 const char * pPoint
;
1697 LPITEMIDLIST pidlTemp
=pidl
;
1699 TRACE("pidl=%p\n",pidl
);
1701 if (!pidl
) return FALSE
;
1703 pidlTemp
= ILFindLastID(pidl
);
1705 if (!_ILIsValue(pidlTemp
)) return FALSE
;
1706 if (!_ILSimpleGetText(pidlTemp
, szTemp
, MAX_PATH
)) return FALSE
;
1708 pPoint
= PathFindExtensionA(szTemp
);
1710 if (! *pPoint
) return FALSE
;
1713 lstrcpynA(pOut
, pPoint
, uOutSize
);
1719 /*************************************************************************
1722 * Given the ItemIdList, get the file type description
1725 * pidl [I] The ItemIDList (simple)
1726 * pOut [I] The buffer to save the result
1727 * uOutsize [I] The size of the buffer
1733 * This function copies as much as possible into the buffer.
1735 void _ILGetFileType(LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1737 if(_ILIsValue(pidl
))
1744 if (_ILGetExtension (pidl
, sTemp
, 64))
1746 if (!( HCR_MapTypeToValue(sTemp
, sTemp
, 64, TRUE
)
1747 && HCR_MapTypeToValue(sTemp
, pOut
, uOutSize
, FALSE
)))
1749 lstrcpynA (pOut
, sTemp
, uOutSize
- 6);
1750 strcat (pOut
, "-file");
1756 lstrcpynA(pOut
, "Folder", uOutSize
);
1760 /*************************************************************************
1761 * _ILGetFileAttributes
1763 * Given the ItemIdList, get the Attrib string format
1766 * pidl [I] The ItemIDList
1767 * pOut [I] The buffer to save the result
1768 * uOutsize [I] The size of the Buffer
1774 * return value 0 in case of error is a valid return value
1777 DWORD
_ILGetFileAttributes(LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1779 LPPIDLDATA pData
=_ILGetDataPointer(pidl
);
1783 if(! pData
) return 0;
1788 wAttrib
= pData
->u
.folder
.uFileAttribs
;
1791 wAttrib
= pData
->u
.file
.uFileAttribs
;
1798 if(wAttrib
& FILE_ATTRIBUTE_READONLY
)
1802 if(wAttrib
& FILE_ATTRIBUTE_HIDDEN
)
1806 if(wAttrib
& FILE_ATTRIBUTE_SYSTEM
)
1810 if(wAttrib
& FILE_ATTRIBUTE_ARCHIVE
)
1814 if(wAttrib
& FILE_ATTRIBUTE_COMPRESSED
)
1823 /*************************************************************************
1826 * free a aPidl struct
1828 void _ILFreeaPidl(LPITEMIDLIST
* apidl
, UINT cidl
)
1834 for(i
= 0; i
< cidl
; i
++) SHFree(apidl
[i
]);
1839 /*************************************************************************
1842 * copys a aPidl struct
1844 LPITEMIDLIST
* _ILCopyaPidl(LPITEMIDLIST
* apidlsrc
, UINT cidl
)
1847 LPITEMIDLIST
* apidldest
= (LPITEMIDLIST
*)SHAlloc(cidl
* sizeof(LPITEMIDLIST
));
1848 if(!apidlsrc
) return NULL
;
1850 for(i
= 0; i
< cidl
; i
++)
1851 apidldest
[i
] = ILClone(apidlsrc
[i
]);
1856 /*************************************************************************
1857 * _ILCopyCidaToaPidl
1859 * creates aPidl from CIDA
1861 LPITEMIDLIST
* _ILCopyCidaToaPidl(LPITEMIDLIST
* pidl
, LPCIDA cida
)
1864 LPITEMIDLIST
* dst
= (LPITEMIDLIST
*)SHAlloc(cida
->cidl
* sizeof(LPITEMIDLIST
));
1866 if(!dst
) return NULL
;
1869 *pidl
= ILClone((LPITEMIDLIST
)(&((LPBYTE
)cida
)[cida
->aoffset
[0]]));
1871 for(i
= 0; i
< cida
->cidl
; i
++)
1872 dst
[i
] = ILClone((LPITEMIDLIST
)(&((LPBYTE
)cida
)[cida
->aoffset
[i
+ 1]]));