4 * Copyright 1998 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * a pidl == NULL means desktop and is legal
33 #include "undocshell.h"
34 #include "shell32_main.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(pidl
);
42 WINE_DECLARE_DEBUG_CHANNEL(shell
);
44 void pdump (LPCITEMIDLIST pidl
)
46 LPITEMIDLIST pidltemp
= pidl
;
52 MESSAGE ("-------- pidl=NULL (Desktop)\n");
56 MESSAGE ("-------- pidl=%p\n", pidl
);
57 if (pidltemp
->mkid
.cb
)
62 LPPIDLDATA pData
= _ILGetDataPointer(pidltemp
);
63 DWORD type
= pData
->type
;
64 LPSTR szLongName
= _ILGetTextPointer(pidltemp
);
65 LPSTR szShortName
= _ILGetSTextPointer(pidltemp
);
66 char szName
[MAX_PATH
];
68 _ILSimpleGetText(pidltemp
, szName
, MAX_PATH
);
69 if( PT_FOLDER
== type
)
70 dwAttrib
= pData
->u
.folder
.uFileAttribs
;
71 else if( PT_VALUE
== type
)
72 dwAttrib
= pData
->u
.file
.uFileAttribs
;
74 MESSAGE ("-- pidl=%p size=%u type=%lx attr=0x%08lx name=%s (%s,%s)\n",
75 pidltemp
, pidltemp
->mkid
.cb
,type
,dwAttrib
,szName
,debugstr_a(szLongName
), debugstr_a(szShortName
));
77 pidltemp
= ILGetNext(pidltemp
);
79 } while (pidltemp
->mkid
.cb
);
83 MESSAGE ("empty pidl (Desktop)\n");
88 #define BYTES_PRINTED 32
89 BOOL
pcheck (LPCITEMIDLIST pidl
)
92 LPITEMIDLIST pidltemp
= pidl
;
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
);
142 /*************************************************************************
143 * ILGetDisplayName [SHELL32.15]
145 BOOL WINAPI
ILGetDisplayName(LPCITEMIDLIST pidl
,LPSTR path
)
147 TRACE_(shell
)("pidl=%p %p semi-stub\n",pidl
,path
);
148 return SHGetPathFromIDListA(pidl
, path
);
150 /*************************************************************************
151 * ILFindLastID [SHELL32.16]
154 * observed: pidl=Desktop return=pidl
156 LPITEMIDLIST WINAPI
ILFindLastID(LPITEMIDLIST pidl
)
157 { LPITEMIDLIST pidlLast
= pidl
;
159 TRACE("(pidl=%p)\n",pidl
);
161 while (pidl
->mkid
.cb
)
164 pidl
= ILGetNext(pidl
);
168 /*************************************************************************
169 * ILRemoveLastID [SHELL32.17]
172 * when pidl=Desktop return=FALSE
174 BOOL WINAPI
ILRemoveLastID(LPCITEMIDLIST pidl
)
176 TRACE_(shell
)("pidl=%p\n",pidl
);
178 if (!pidl
|| !pidl
->mkid
.cb
)
180 ILFindLastID(pidl
)->mkid
.cb
= 0;
184 /*************************************************************************
185 * ILClone [SHELL32.18]
188 * duplicate an idlist
190 LPITEMIDLIST WINAPI
ILClone (LPCITEMIDLIST pidl
)
192 LPITEMIDLIST newpidl
;
197 len
= ILGetSize(pidl
);
198 newpidl
= (LPITEMIDLIST
)SHAlloc(len
);
200 memcpy(newpidl
,pidl
,len
);
202 TRACE("pidl=%p newpidl=%p\n",pidl
, newpidl
);
207 /*************************************************************************
208 * ILCloneFirst [SHELL32.19]
211 * duplicates the first idlist of a complex pidl
213 LPITEMIDLIST WINAPI
ILCloneFirst(LPCITEMIDLIST pidl
)
215 LPITEMIDLIST pidlNew
= NULL
;
217 TRACE("pidl=%p \n",pidl
);
223 pidlNew
= (LPITEMIDLIST
) SHAlloc (len
+2);
226 memcpy(pidlNew
,pidl
,len
+2); /* 2 -> mind a desktop pidl */
229 ILGetNext(pidlNew
)->mkid
.cb
= 0x00;
232 TRACE("-- newpidl=%p\n",pidlNew
);
237 /*************************************************************************
238 * ILLoadFromStream (SHELL32.26)
241 * the first two bytes are the len, the pidl is following then
243 HRESULT WINAPI
ILLoadFromStream (IStream
* pStream
, LPITEMIDLIST
* ppPidl
)
246 HRESULT ret
= E_FAIL
;
249 TRACE_(shell
)("%p %p\n", pStream
, ppPidl
);
256 IStream_AddRef (pStream
);
258 if (SUCCEEDED(IStream_Read(pStream
, (LPVOID
)&wLen
, 2, &dwBytesRead
)))
259 { *ppPidl
= SHAlloc (wLen
);
260 if (SUCCEEDED(IStream_Read(pStream
, *ppPidl
, wLen
, &dwBytesRead
)))
269 /* we are not yet fully compatible */
270 if (!pcheck(*ppPidl
))
276 IStream_Release (pStream
);
281 /*************************************************************************
282 * ILSaveToStream (SHELL32.27)
285 * the first two bytes are the len, the pidl is following then
287 HRESULT WINAPI
ILSaveToStream (IStream
* pStream
, LPCITEMIDLIST pPidl
)
291 HRESULT ret
= E_FAIL
;
293 TRACE_(shell
)("%p %p\n", pStream
, pPidl
);
295 IStream_AddRef (pStream
);
298 while (pidl
->mkid
.cb
)
300 wLen
+= sizeof(WORD
) + pidl
->mkid
.cb
;
301 pidl
= ILGetNext(pidl
);
304 if (SUCCEEDED(IStream_Write(pStream
, (LPVOID
)&wLen
, 2, NULL
)))
306 if (SUCCEEDED(IStream_Write(pStream
, pPidl
, wLen
, NULL
)))
312 IStream_Release (pStream
);
317 /*************************************************************************
318 * SHILCreateFromPath [SHELL32.28]
321 * wraper for IShellFolder::ParseDisplayName()
323 HRESULT WINAPI
SHILCreateFromPathA (LPCSTR path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
325 WCHAR lpszDisplayName
[MAX_PATH
];
327 HRESULT ret
= E_FAIL
;
329 TRACE_(shell
)("%s %p 0x%08lx\n",path
,ppidl
,attributes
?*attributes
:0);
331 if (!MultiByteToWideChar( CP_ACP
, 0, path
, -1, lpszDisplayName
, MAX_PATH
))
332 lpszDisplayName
[MAX_PATH
-1] = 0;
334 if (SUCCEEDED (SHGetDesktopFolder(&sf
)))
336 ret
= IShellFolder_ParseDisplayName(sf
,0, NULL
,lpszDisplayName
,&pchEaten
,ppidl
,attributes
);
337 IShellFolder_Release(sf
);
341 HRESULT WINAPI
SHILCreateFromPathW (LPCWSTR path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
344 HRESULT ret
= E_FAIL
;
346 TRACE_(shell
)("%s %p 0x%08lx\n",debugstr_w(path
),ppidl
,attributes
?*attributes
:0);
348 if (SUCCEEDED (SHGetDesktopFolder(&sf
)))
350 ret
= IShellFolder_ParseDisplayName(sf
,0, NULL
, (LPWSTR
) path
, &pchEaten
, ppidl
, attributes
);
351 IShellFolder_Release(sf
);
355 HRESULT WINAPI
SHILCreateFromPathAW (LPCVOID path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
357 if ( SHELL_OsIsUnicode())
358 return SHILCreateFromPathW (path
, ppidl
, attributes
);
359 return SHILCreateFromPathA (path
, ppidl
, attributes
);
362 /*************************************************************************
363 * SHCloneSpecialIDList [SHELL32.89]
367 * nFolder [in] CSIDL_xxxxx ??
372 * exported by ordinal
374 LPITEMIDLIST WINAPI
SHCloneSpecialIDList(HWND hwndOwner
,DWORD nFolder
,DWORD x3
)
375 { LPITEMIDLIST ppidl
;
376 WARN_(shell
)("(hwnd=0x%x,csidl=0x%lx,0x%lx):semi-stub.\n",
377 hwndOwner
,nFolder
,x3
);
379 SHGetSpecialFolderLocation(hwndOwner
, nFolder
, &ppidl
);
384 /*************************************************************************
385 * ILGlobalClone [SHELL32.20]
388 LPITEMIDLIST WINAPI
ILGlobalClone(LPCITEMIDLIST pidl
)
390 LPITEMIDLIST newpidl
;
395 len
= ILGetSize(pidl
);
396 newpidl
= (LPITEMIDLIST
)pCOMCTL32_Alloc(len
);
398 memcpy(newpidl
,pidl
,len
);
400 TRACE("pidl=%p newpidl=%p\n",pidl
, newpidl
);
406 /*************************************************************************
407 * ILIsEqual [SHELL32.21]
410 BOOL WINAPI
ILIsEqual(LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
412 char szData1
[MAX_PATH
];
413 char szData2
[MAX_PATH
];
415 LPITEMIDLIST pidltemp1
= pidl1
;
416 LPITEMIDLIST pidltemp2
= pidl2
;
418 TRACE("pidl1=%p pidl2=%p\n",pidl1
, pidl2
);
420 /* explorer reads from registry directly (StreamMRU),
421 so we can only check here */
422 if ((!pcheck (pidl1
)) || (!pcheck (pidl2
))) return FALSE
;
427 if ( (!pidl1
) || (!pidl2
) ) return FALSE
;
429 while (pidltemp1
->mkid
.cb
&& pidltemp2
->mkid
.cb
)
431 _ILSimpleGetText(pidltemp1
, szData1
, MAX_PATH
);
432 _ILSimpleGetText(pidltemp2
, szData2
, MAX_PATH
);
434 if (strcasecmp ( szData1
, szData2
)!=0 )
437 pidltemp1
= ILGetNext(pidltemp1
);
438 pidltemp2
= ILGetNext(pidltemp2
);
441 if (!pidltemp1
->mkid
.cb
&& !pidltemp2
->mkid
.cb
)
448 /*************************************************************************
449 * ILIsParent [SHELL32.23]
451 * parent=a/b child=a/b/c -> true, c is in folder a/b
452 * child=a/b/c/d -> false if bImmediate is true, d is not in folder a/b
453 * child=a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b
455 BOOL WINAPI
ILIsParent( LPCITEMIDLIST pidlParent
, LPCITEMIDLIST pidlChild
, BOOL bImmediate
)
457 char szData1
[MAX_PATH
];
458 char szData2
[MAX_PATH
];
460 LPITEMIDLIST pParent
= pidlParent
;
461 LPITEMIDLIST pChild
= pidlChild
;
463 TRACE("%p %p %x\n", pidlParent
, pidlChild
, bImmediate
);
465 while (pParent
->mkid
.cb
&& pChild
->mkid
.cb
)
467 _ILSimpleGetText(pParent
, szData1
, MAX_PATH
);
468 _ILSimpleGetText(pChild
, szData2
, MAX_PATH
);
470 if (strcasecmp ( szData1
, szData2
)!=0 )
473 pParent
= ILGetNext(pParent
);
474 pChild
= ILGetNext(pChild
);
477 if ( pParent
->mkid
.cb
|| ! pChild
->mkid
.cb
) /* child shorter or has equal length to parent */
480 if ( ILGetNext(pChild
)->mkid
.cb
&& bImmediate
) /* not immediate descent */
486 /*************************************************************************
487 * ILFindChild [SHELL32.24]
490 * Compares elements from pidl1 and pidl2.
492 * pidl1 is desktop pidl2
493 * pidl1 shorter pidl2 pointer to first different element of pidl2
494 * if there was at least one equal element
495 * pidl2 shorter pidl1 0
496 * pidl2 equal pidl1 pointer to last 0x00-element of pidl2
498 LPITEMIDLIST WINAPI
ILFindChild(LPCITEMIDLIST pidl1
,LPCITEMIDLIST pidl2
)
500 char szData1
[MAX_PATH
];
501 char szData2
[MAX_PATH
];
503 LPITEMIDLIST pidltemp1
= pidl1
;
504 LPITEMIDLIST pidltemp2
= pidl2
;
505 LPITEMIDLIST ret
=NULL
;
507 TRACE("pidl1=%p pidl2=%p\n",pidl1
, pidl2
);
509 /* explorer reads from registry directly (StreamMRU),
510 so we can only check here */
511 if ((!pcheck (pidl1
)) || (!pcheck (pidl2
)))
517 if ( _ILIsDesktop(pidl1
) )
523 while (pidltemp1
->mkid
.cb
&& pidltemp2
->mkid
.cb
)
525 _ILSimpleGetText(pidltemp1
, szData1
, MAX_PATH
);
526 _ILSimpleGetText(pidltemp2
, szData2
, MAX_PATH
);
528 if (strcasecmp(szData1
,szData2
))
531 pidltemp1
= ILGetNext(pidltemp1
);
532 pidltemp2
= ILGetNext(pidltemp2
);
536 if (pidltemp1
->mkid
.cb
)
538 ret
= NULL
; /* elements of pidl1 left*/
541 TRACE_(shell
)("--- %p\n", ret
);
542 return ret
; /* pidl 1 is shorter */
545 /*************************************************************************
546 * ILCombine [SHELL32.25]
549 * Concatenates two complex idlists.
550 * The pidl is the first one, pidlsub the next one
551 * Does not destroy the passed in idlists!
553 LPITEMIDLIST WINAPI
ILCombine(LPCITEMIDLIST pidl1
,LPCITEMIDLIST pidl2
)
556 LPITEMIDLIST pidlNew
;
558 TRACE("pidl=%p pidl=%p\n",pidl1
,pidl2
);
560 if(!pidl1
&& !pidl2
) return NULL
;
567 pidlNew
= ILClone(pidl2
);
573 pidlNew
= ILClone(pidl1
);
577 len1
= ILGetSize(pidl1
)-2;
578 len2
= ILGetSize(pidl2
);
579 pidlNew
= SHAlloc(len1
+len2
);
583 memcpy(pidlNew
,pidl1
,len1
);
584 memcpy(((BYTE
*)pidlNew
)+len1
,pidl2
,len2
);
587 /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/
590 /*************************************************************************
591 * SHGetRealIDL [SHELL32.98]
595 LPITEMIDLIST WINAPI
SHGetRealIDL(LPSHELLFOLDER lpsf
, LPITEMIDLIST pidl
, DWORD z
)
597 FIXME("sf=%p pidl=%p 0x%04lx\n",lpsf
,pidl
,z
);
603 /*************************************************************************
604 * SHLogILFromFSIL [SHELL32.95]
607 * pild = CSIDL_DESKTOP ret = 0
608 * pild = CSIDL_DRIVES ret = 0
610 LPITEMIDLIST WINAPI
SHLogILFromFSIL(LPITEMIDLIST pidl
)
612 FIXME("(pidl=%p)\n",pidl
);
619 /*************************************************************************
620 * ILGetSize [SHELL32.152]
621 * gets the byte size of an idlist including zero terminator (pidl)
630 * exported by ordinal
632 DWORD WINAPI
ILGetSize(LPITEMIDLIST pidl
)
634 LPSHITEMID si
= &(pidl
->mkid
);
640 si
= (LPSHITEMID
)(((LPBYTE
)si
)+si
->cb
);
644 TRACE("pidl=%p size=%lu\n",pidl
, len
);
648 /*************************************************************************
649 * ILGetNext [SHELL32.153]
650 * gets the next simple pidl of a complex pidl
652 * observed return values:
655 * simple pidl -> pointer to 0x0000 element
658 LPITEMIDLIST WINAPI
ILGetNext(LPITEMIDLIST pidl
)
667 pidl
= (LPITEMIDLIST
) (((LPBYTE
)pidl
)+len
);
673 /*************************************************************************
674 * ILAppend [SHELL32.154]
677 * Adds the single item to the idlist indicated by pidl.
678 * if bEnd is 0, adds the item to the front of the list,
679 * otherwise adds the item to the end. (???)
680 * Destroys the passed in idlist! (???)
682 LPITEMIDLIST WINAPI
ILAppend(LPITEMIDLIST pidl
,LPCITEMIDLIST item
,BOOL bEnd
)
686 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl
,item
,bEnd
);
691 if (_ILIsDesktop(pidl
))
693 idlRet
= ILClone(item
);
701 idlRet
=ILCombine(pidl
,item
);
705 idlRet
=ILCombine(item
,pidl
);
711 /*************************************************************************
712 * ILFree [SHELL32.155]
715 * free_check_ptr - frees memory (if not NULL)
716 * allocated by SHMalloc allocator
717 * exported by ordinal
719 DWORD WINAPI
ILFree(LPITEMIDLIST pidl
)
721 TRACE("(pidl=0x%08lx)\n",(DWORD
)pidl
);
723 if(!pidl
) return FALSE
;
727 /*************************************************************************
728 * ILGlobalFree [SHELL32.156]
731 void WINAPI
ILGlobalFree( LPCITEMIDLIST pidl
)
736 pCOMCTL32_Free(pidl
);
738 /*************************************************************************
739 * ILCreateFromPath [SHELL32.157]
742 LPITEMIDLIST WINAPI
ILCreateFromPathA (LPCSTR path
)
744 LPITEMIDLIST pidlnew
;
745 DWORD attributes
= 0;
747 TRACE_(shell
)("%s\n",path
);
749 if (SUCCEEDED (SHILCreateFromPathA (path
, &pidlnew
, &attributes
)))
753 LPITEMIDLIST WINAPI
ILCreateFromPathW (LPCWSTR path
)
755 LPITEMIDLIST pidlnew
;
756 DWORD attributes
= 0;
758 TRACE_(shell
)("%s\n",debugstr_w(path
));
760 if (SUCCEEDED (SHILCreateFromPathW (path
, &pidlnew
, &attributes
)))
764 LPITEMIDLIST WINAPI
ILCreateFromPathAW (LPCVOID path
)
766 if ( SHELL_OsIsUnicode())
767 return ILCreateFromPathW (path
);
768 return ILCreateFromPathA (path
);
770 /*************************************************************************
771 * SHSimpleIDListFromPath [SHELL32.162]
773 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathA (LPCSTR lpszPath
)
775 LPITEMIDLIST pidl
=NULL
;
777 WIN32_FIND_DATAA stffile
;
779 TRACE("path=%s\n", lpszPath
);
781 if (!lpszPath
) return NULL
;
783 hFile
= FindFirstFileA(lpszPath
, &stffile
);
785 if ( hFile
!= INVALID_HANDLE_VALUE
)
787 if (stffile
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
789 pidl
= _ILCreateFolder (&stffile
);
793 pidl
= _ILCreateValue (&stffile
);
799 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathW (LPCWSTR lpszPath
)
801 char lpszTemp
[MAX_PATH
];
802 TRACE("path=%s\n",debugstr_w(lpszPath
));
804 if (!WideCharToMultiByte( CP_ACP
, 0, lpszPath
, -1, lpszTemp
, sizeof(lpszTemp
), NULL
, NULL
))
805 lpszTemp
[sizeof(lpszTemp
)-1] = 0;
807 return SHSimpleIDListFromPathA (lpszTemp
);
810 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathAW (LPCVOID lpszPath
)
812 if ( SHELL_OsIsUnicode())
813 return SHSimpleIDListFromPathW (lpszPath
);
814 return SHSimpleIDListFromPathA (lpszPath
);
817 /*************************************************************************
818 * SHGetSpecialFolderLocation [SHELL32.@]
820 * gets the folder locations from the registry and creates a pidl
821 * creates missing reg keys and directories
825 * nFolder [I] CSIDL_xxxxx
826 * ppidl [O] PIDL of a special folder
829 HRESULT WINAPI
SHGetSpecialFolderLocation(
832 LPITEMIDLIST
* ppidl
)
834 CHAR szPath
[MAX_PATH
];
835 HRESULT hr
= E_INVALIDARG
;
837 TRACE_(shell
)("(%04x,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
845 *ppidl
= _ILCreateDesktop();
849 *ppidl
= _ILCreateMyComputer();
853 *ppidl
= _ILCreateNetwork ();
857 *ppidl
= _ILCreateControl ();
861 *ppidl
= _ILCreatePrinter ();
864 case CSIDL_BITBUCKET
:
865 *ppidl
= _ILCreateBitBucket ();
869 if (SHGetSpecialFolderPathA(hwndOwner
, szPath
, nFolder
, TRUE
))
872 TRACE_(shell
)("Value=%s\n",szPath
);
873 hr
= SHILCreateFromPathA(szPath
, ppidl
, &attributes
);
876 if(*ppidl
) hr
= NOERROR
;
879 TRACE_(shell
)("-- (new pidl %p)\n",*ppidl
);
883 /*************************************************************************
884 * SHGetFolderLocation [SHELL32.@]
887 * the pidl can be a simple one. since we cant get the path out of the pidl
888 * we have to take all data from the pidl
890 HRESULT WINAPI
SHGetFolderLocation(
897 FIXME("0x%04x 0x%08x 0x%08x 0x%08lx %p\n",
898 hwnd
, csidl
, hToken
, dwFlags
, ppidl
);
899 return SHGetSpecialFolderLocation(hwnd
, csidl
, ppidl
);
902 /*************************************************************************
903 * SHGetDataFromIDListA [SHELL32.247]
906 * the pidl can be a simple one. since we cant get the path out of the pidl
907 * we have to take all data from the pidl
909 HRESULT WINAPI
SHGetDataFromIDListA(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, int nFormat
, LPVOID dest
, int len
)
911 TRACE_(shell
)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf
,pidl
,nFormat
,dest
,len
);
914 if (!psf
|| !dest
) return E_INVALIDARG
;
918 case SHGDFIL_FINDDATA
:
920 WIN32_FIND_DATAA
* pfd
= dest
;
922 if ( len
< sizeof (WIN32_FIND_DATAA
)) return E_INVALIDARG
;
924 ZeroMemory(pfd
, sizeof (WIN32_FIND_DATAA
));
925 _ILGetFileDateTime( pidl
, &(pfd
->ftLastWriteTime
));
926 pfd
->dwFileAttributes
= _ILGetFileAttributes(pidl
, NULL
, 0);
927 pfd
->nFileSizeLow
= _ILGetFileSize ( pidl
, NULL
, 0);
928 lstrcpynA(pfd
->cFileName
,_ILGetTextPointer(pidl
), MAX_PATH
);
929 lstrcpynA(pfd
->cAlternateFileName
,_ILGetSTextPointer(pidl
), 14);
933 case SHGDFIL_NETRESOURCE
:
934 case SHGDFIL_DESCRIPTIONID
:
935 FIXME_(shell
)("SHGDFIL %i stub\n", nFormat
);
939 ERR_(shell
)("Unknown SHGDFIL %i, please report\n", nFormat
);
944 /*************************************************************************
945 * SHGetDataFromIDListW [SHELL32.248]
948 HRESULT WINAPI
SHGetDataFromIDListW(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, int nFormat
, LPVOID dest
, int len
)
950 TRACE_(shell
)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf
,pidl
,nFormat
,dest
,len
);
954 if (! psf
|| !dest
) return E_INVALIDARG
;
958 case SHGDFIL_FINDDATA
:
960 WIN32_FIND_DATAW
* pfd
= dest
;
962 if ( len
< sizeof (WIN32_FIND_DATAW
)) return E_INVALIDARG
;
964 ZeroMemory(pfd
, sizeof (WIN32_FIND_DATAA
));
965 _ILGetFileDateTime( pidl
, &(pfd
->ftLastWriteTime
));
966 pfd
->dwFileAttributes
= _ILGetFileAttributes(pidl
, NULL
, 0);
967 pfd
->nFileSizeLow
= _ILGetFileSize ( pidl
, NULL
, 0);
968 if (!MultiByteToWideChar( CP_ACP
, 0, _ILGetTextPointer(pidl
), -1,
969 pfd
->cFileName
, MAX_PATH
))
970 pfd
->cFileName
[MAX_PATH
-1] = 0;
971 if (!MultiByteToWideChar( CP_ACP
, 0, _ILGetSTextPointer(pidl
), -1,
972 pfd
->cAlternateFileName
, 14 ))
973 pfd
->cFileName
[13] = 0;
976 case SHGDFIL_NETRESOURCE
:
977 case SHGDFIL_DESCRIPTIONID
:
978 FIXME_(shell
)("SHGDFIL %i stub\n", nFormat
);
982 ERR_(shell
)("Unknown SHGDFIL %i, please report\n", nFormat
);
988 /*************************************************************************
989 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
996 * path from a passed PIDL.
1000 * desktop pidl gives path to desktopdirectory back
1001 * special pidls returning FALSE
1004 * fnGetDisplayNameOf can return different types of OLEString
1006 BOOL WINAPI
SHGetPathFromIDListA (LPCITEMIDLIST pidl
,LPSTR pszPath
)
1008 LPSHELLFOLDER shellfolder
;
1010 TRACE_(shell
)("(pidl=%p,%p)\n",pidl
,pszPath
);
1012 if (!pidl
) return FALSE
;
1016 if(_ILIsDesktop(pidl
))
1018 SHGetSpecialFolderPathA(0, pszPath
, CSIDL_DESKTOPDIRECTORY
, FALSE
);
1020 else if (_ILIsSpecialFolder(ILFindLastID(pidl
)))
1022 /* we are somewhere in a special folder */
1027 if (SHGetDesktopFolder(&shellfolder
)==S_OK
)
1029 IShellFolder_GetDisplayNameOf(shellfolder
,pidl
,SHGDN_FORPARSING
,&str
);
1030 StrRetToStrNA (pszPath
, MAX_PATH
, &str
, pidl
);
1031 IShellFolder_Release(shellfolder
);
1034 TRACE_(shell
)("-- (%s)\n",pszPath
);
1038 /*************************************************************************
1039 * SHGetPathFromIDListW [SHELL32.@]
1041 BOOL WINAPI
SHGetPathFromIDListW (LPCITEMIDLIST pidl
,LPWSTR pszPath
)
1042 { char sTemp
[MAX_PATH
];
1044 TRACE_(shell
)("(pidl=%p)\n", pidl
);
1046 SHGetPathFromIDListA (pidl
, sTemp
);
1047 MultiByteToWideChar( CP_ACP
, 0, sTemp
, -1, pszPath
, MAX_PATH
);
1049 TRACE_(shell
)("-- (%s)\n",debugstr_w(pszPath
));
1054 /*************************************************************************
1055 * SHBindToParent [shell version 5.0]
1057 HRESULT WINAPI
SHBindToParent(LPCITEMIDLIST pidl
, REFIID riid
, LPVOID
*ppv
, LPCITEMIDLIST
*ppidlLast
)
1060 LPITEMIDLIST pidlChild
, pidlParent
;
1063 TRACE_(shell
)("pidl=%p\n", pidl
);
1067 if (ppidlLast
) *ppidlLast
= NULL
;
1069 if (_ILIsPidlSimple(pidl
))
1071 /* we are on desktop level */
1073 *ppidlLast
= ILClone(pidl
);
1074 hr
= SHGetDesktopFolder((IShellFolder
**)ppv
);
1078 pidlChild
= ILClone(ILFindLastID(pidl
));
1079 pidlParent
= ILClone(pidl
);
1080 ILRemoveLastID(pidlParent
);
1082 hr
= SHGetDesktopFolder(&psf
);
1085 hr
= IShellFolder_BindToObject(psf
, pidlParent
, NULL
, riid
, ppv
);
1087 if (SUCCEEDED(hr
) && ppidlLast
)
1088 *ppidlLast
= pidlChild
;
1092 SHFree (pidlParent
);
1093 if (psf
) IShellFolder_Release(psf
);
1097 TRACE_(shell
)("-- psf=%p pidl=%p ret=0x%08lx\n", *ppv
, (ppidlLast
)?*ppidlLast
:NULL
, hr
);
1101 /*************************************************************************
1102 * SHGetPathFromIDList [SHELL32.@][NT 4.0: SHELL32.219]
1104 BOOL WINAPI
SHGetPathFromIDListAW(LPCITEMIDLIST pidl
,LPVOID pszPath
)
1106 TRACE_(shell
)("(pidl=%p,%p)\n",pidl
,pszPath
);
1108 if (SHELL_OsIsUnicode())
1109 return SHGetPathFromIDListW(pidl
,pszPath
);
1110 return SHGetPathFromIDListA(pidl
,pszPath
);
1113 /**************************************************************************
1115 * internal functions
1117 * ### 1. section creating pidls ###
1119 *************************************************************************
1120 * _ILCreateDesktop()
1121 * _ILCreateIExplore()
1122 * _ILCreateMyComputer()
1127 LPITEMIDLIST
_ILCreateDesktop()
1129 return _ILCreate(PT_DESKTOP
, NULL
, 0);
1132 LPITEMIDLIST
_ILCreateMyComputer()
1134 return _ILCreate(PT_MYCOMP
, &CLSID_MyComputer
, sizeof(GUID
));
1137 LPITEMIDLIST
_ILCreateIExplore()
1139 return _ILCreate(PT_MYCOMP
, &CLSID_Internet
, sizeof(GUID
));
1142 LPITEMIDLIST
_ILCreateControl()
1144 return _ILCreate(PT_SPECIAL
, &CLSID_ControlPanel
, sizeof(GUID
));
1147 LPITEMIDLIST
_ILCreatePrinter()
1149 return _ILCreate(PT_SPECIAL
, &CLSID_Printers
, sizeof(GUID
));
1152 LPITEMIDLIST
_ILCreateNetwork()
1154 return _ILCreate(PT_MYCOMP
, &CLSID_NetworkPlaces
, sizeof(GUID
));
1157 LPITEMIDLIST
_ILCreateBitBucket()
1159 return _ILCreate(PT_MYCOMP
, &CLSID_RecycleBin
, sizeof(GUID
));
1162 LPITEMIDLIST
_ILCreateDrive( LPCSTR lpszNew
)
1164 lstrcpynA (sTemp
,lpszNew
,4);
1167 TRACE("(%s)\n",sTemp
);
1168 return _ILCreate(PT_DRIVE
,(LPVOID
)&sTemp
[0],4);
1171 LPITEMIDLIST
_ILCreateFolder( WIN32_FIND_DATAA
* stffile
)
1173 char buff
[MAX_PATH
+ 14 +1]; /* see WIN32_FIND_DATA */
1174 char * pbuff
= buff
;
1178 TRACE("(%s, %s)\n",stffile
->cAlternateFileName
, stffile
->cFileName
);
1180 /* prepare buffer with both names */
1181 len
= strlen (stffile
->cFileName
) + 1;
1182 memcpy (pbuff
, stffile
->cFileName
, len
);
1185 if (stffile
->cAlternateFileName
)
1187 len1
= strlen (stffile
->cAlternateFileName
)+1;
1188 memcpy (pbuff
, stffile
->cAlternateFileName
, len1
);
1196 pidl
= _ILCreate(PT_FOLDER
, (LPVOID
)buff
, len
+ len1
);
1198 /* set attributes */
1202 pData
= _ILGetDataPointer(pidl
);
1203 FileTimeToDosDateTime(&(stffile
->ftLastWriteTime
),&pData
->u
.folder
.uFileDate
,&pData
->u
.folder
.uFileTime
);
1204 pData
->u
.folder
.dwFileSize
= stffile
->nFileSizeLow
;
1205 pData
->u
.folder
.uFileAttribs
=stffile
->dwFileAttributes
;
1211 LPITEMIDLIST
_ILCreateValue(WIN32_FIND_DATAA
* stffile
)
1213 char buff
[MAX_PATH
+ 14 +1]; /* see WIN32_FIND_DATA */
1214 char * pbuff
= buff
;
1218 TRACE("(%s, %s)\n",stffile
->cAlternateFileName
, stffile
->cFileName
);
1220 /* prepare buffer with both names */
1221 len
= strlen (stffile
->cFileName
) + 1;
1222 memcpy (pbuff
, stffile
->cFileName
, len
);
1225 if (stffile
->cAlternateFileName
)
1227 len1
= strlen (stffile
->cAlternateFileName
)+1;
1228 memcpy (pbuff
, stffile
->cAlternateFileName
, len1
);
1236 pidl
= _ILCreate(PT_VALUE
, (LPVOID
)buff
, len
+ len1
);
1238 /* set attributes */
1242 pData
= _ILGetDataPointer(pidl
);
1243 FileTimeToDosDateTime(&(stffile
->ftLastWriteTime
),&pData
->u
.folder
.uFileDate
,&pData
->u
.folder
.uFileTime
);
1244 pData
->u
.folder
.dwFileSize
= stffile
->nFileSizeLow
;
1245 pData
->u
.folder
.uFileAttribs
=stffile
->dwFileAttributes
;
1251 LPITEMIDLIST
_ILCreateSpecial(LPCSTR szGUID
)
1256 if (!MultiByteToWideChar( CP_ACP
, 0, szGUID
, -1, buffer
, sizeof(buffer
)/sizeof(WCHAR
) ))
1258 CLSIDFromString( buffer
, &iid
);
1259 return _ILCreate(PT_MYCOMP
, &iid
, sizeof(IID
));
1262 /**************************************************************************
1264 * Creates a new PIDL
1265 * type = PT_DESKTOP | PT_DRIVE | PT_FOLDER | PT_VALUE
1267 * uInSize = size of data (raw)
1270 LPITEMIDLIST
_ILCreate(PIDLTYPE type
, LPCVOID pIn
, UINT uInSize
)
1272 LPITEMIDLIST pidlOut
= NULL
, pidlTemp
= NULL
;
1277 TRACE("(0x%02x %p %i)\n",type
,pIn
,uInSize
);
1286 uSize
= 2 + 2 + sizeof(GUID
);
1293 uSize
= 2 + 12 + uInSize
;
1296 FIXME("can't create type: 0x%08x\n",type
);
1300 if(!(pidlOut
= SHAlloc(uSize
+ 2))) return NULL
;
1301 ZeroMemory(pidlOut
, uSize
+ 2);
1302 pidlOut
->mkid
.cb
= uSize
;
1307 TRACE("- create Desktop\n");
1312 pData
=_ILGetDataPointer(pidlOut
);
1314 memcpy(&(pData
->u
.mycomp
.guid
), pIn
, uInSize
);
1315 TRACE("- create GUID-pidl\n");
1319 pData
=_ILGetDataPointer(pidlOut
);
1321 pszDest
= _ILGetTextPointer(pidlOut
);
1322 memcpy(pszDest
, pIn
, uInSize
);
1323 TRACE("- create Drive: %s\n",debugstr_a(pszDest
));
1328 pData
=_ILGetDataPointer(pidlOut
);
1330 pszDest
= _ILGetTextPointer(pidlOut
);
1331 memcpy(pszDest
, pIn
, uInSize
);
1332 TRACE("- create Value: %s\n",debugstr_a(pszDest
));
1336 pidlTemp
= ILGetNext(pidlOut
);
1338 pidlTemp
->mkid
.cb
= 0x00;
1340 TRACE("-- (pidl=%p, size=%u)\n", pidlOut
, uSize
);
1344 /**************************************************************************
1347 * Gets the text for the drive eg. 'c:\'
1352 DWORD
_ILGetDrive(LPCITEMIDLIST pidl
,LPSTR pOut
, UINT uSize
)
1353 { TRACE("(%p,%p,%u)\n",pidl
,pOut
,uSize
);
1355 if(_ILIsMyComputer(pidl
))
1356 pidl
= ILGetNext(pidl
);
1358 if (pidl
&& _ILIsDrive(pidl
))
1359 return _ILSimpleGetText(pidl
, pOut
, uSize
);
1364 /**************************************************************************
1366 * ### 2. section testing pidls ###
1368 **************************************************************************
1371 * _ILIsSpecialFolder()
1377 BOOL
_ILIsDesktop(LPCITEMIDLIST pidl
)
1378 { TRACE("(%p)\n",pidl
);
1379 return ( !pidl
|| (pidl
&& pidl
->mkid
.cb
== 0x00) );
1382 BOOL
_ILIsMyComputer(LPCITEMIDLIST pidl
)
1384 REFIID iid
= _ILGetGUIDPointer(pidl
);
1386 TRACE("(%p)\n",pidl
);
1389 return IsEqualIID(iid
, &CLSID_MyComputer
);
1393 BOOL
_ILIsSpecialFolder (LPCITEMIDLIST pidl
)
1395 LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1396 TRACE("(%p)\n",pidl
);
1397 return (pidl
&& ( (lpPData
&& (PT_MYCOMP
== lpPData
->type
|| PT_SPECIAL
== lpPData
->type
)) ||
1398 (pidl
&& pidl
->mkid
.cb
== 0x00)
1402 BOOL
_ILIsDrive(LPCITEMIDLIST pidl
)
1403 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1404 TRACE("(%p)\n",pidl
);
1405 return (pidl
&& lpPData
&& (PT_DRIVE
== lpPData
->type
||
1406 PT_DRIVE1
== lpPData
->type
||
1407 PT_DRIVE2
== lpPData
->type
||
1408 PT_DRIVE3
== lpPData
->type
));
1411 BOOL
_ILIsFolder(LPCITEMIDLIST pidl
)
1412 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1413 TRACE("(%p)\n",pidl
);
1414 return (pidl
&& lpPData
&& (PT_FOLDER
== lpPData
->type
|| PT_FOLDER1
== lpPData
->type
));
1417 BOOL
_ILIsValue(LPCITEMIDLIST pidl
)
1418 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1419 TRACE("(%p)\n",pidl
);
1420 return (pidl
&& lpPData
&& PT_VALUE
== lpPData
->type
);
1423 /**************************************************************************
1426 BOOL
_ILIsPidlSimple ( LPCITEMIDLIST pidl
)
1430 if(! _ILIsDesktop(pidl
)) /* pidl=NULL or mkid.cb=0 */
1432 WORD len
= pidl
->mkid
.cb
;
1433 LPCITEMIDLIST pidlnext
= (LPCITEMIDLIST
) (((LPBYTE
)pidl
) + len
);
1434 if (pidlnext
->mkid
.cb
)
1438 TRACE("%s\n", ret
? "Yes" : "No");
1442 /**************************************************************************
1444 * ### 3. section getting values from pidls ###
1447 /**************************************************************************
1450 * gets the text for the first item in the pidl (eg. simple pidl)
1452 * returns the length of the string
1454 DWORD
_ILSimpleGetText (LPCITEMIDLIST pidl
, LPSTR szOut
, UINT uOutSize
)
1459 char szTemp
[MAX_PATH
];
1461 TRACE("(%p %p %x)\n",pidl
,szOut
,uOutSize
);
1463 if (!pidl
) return 0;
1468 if (_ILIsDesktop(pidl
))
1471 if (HCR_GetClassName(&CLSID_ShellDesktop
, szTemp
, MAX_PATH
))
1474 lstrcpynA(szOut
, szTemp
, uOutSize
);
1476 dwReturn
= strlen (szTemp
);
1479 else if (( szSrc
= _ILGetTextPointer(pidl
) ))
1483 lstrcpynA(szOut
, szSrc
, uOutSize
);
1485 dwReturn
= strlen(szSrc
);
1487 else if (( riid
= _ILGetGUIDPointer(pidl
) ))
1489 /* special folder */
1490 if ( HCR_GetClassName(riid
, szTemp
, MAX_PATH
) )
1493 lstrcpynA(szOut
, szTemp
, uOutSize
);
1495 dwReturn
= strlen (szTemp
);
1500 ERR("-- no text\n");
1503 TRACE("-- (%p=%s 0x%08lx)\n",szOut
,debugstr_a(szOut
),dwReturn
);
1507 /**************************************************************************
1509 * ### 4. getting pointers to parts of pidls ###
1511 **************************************************************************
1512 * _ILGetDataPointer()
1514 LPPIDLDATA
_ILGetDataPointer(LPITEMIDLIST pidl
)
1516 if(pidl
&& pidl
->mkid
.cb
!= 0x00)
1517 return (LPPIDLDATA
) &(pidl
->mkid
.abID
);
1521 /**************************************************************************
1522 * _ILGetTextPointer()
1523 * gets a pointer to the long filename string stored in the pidl
1525 LPSTR
_ILGetTextPointer(LPCITEMIDLIST pidl
)
1526 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1528 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1532 switch (pdata
->type
)
1542 return (LPSTR
)&(pdata
->u
.drive
.szDriveName
);
1549 return (LPSTR
)&(pdata
->u
.file
.szNames
);
1555 return (LPSTR
)&(pdata
->u
.network
.szNames
);
1561 /**************************************************************************
1562 * _ILGetSTextPointer()
1563 * gets a pointer to the short filename string stored in the pidl
1565 LPSTR
_ILGetSTextPointer(LPCITEMIDLIST pidl
)
1566 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1568 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1572 switch (pdata
->type
)
1578 return (LPSTR
)(pdata
->u
.file
.szNames
+ strlen (pdata
->u
.file
.szNames
) + 1);
1581 return (LPSTR
)(pdata
->u
.network
.szNames
+ strlen (pdata
->u
.network
.szNames
) + 1);
1587 /**************************************************************************
1588 * _ILGetGUIDPointer()
1590 * returns reference to guid stored in some pidls
1592 REFIID
_ILGetGUIDPointer(LPCITEMIDLIST pidl
)
1594 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1596 TRACE("%p\n", pidl
);
1600 TRACE("pdata->type 0x%04x\n", pdata
->type
);
1601 switch (pdata
->type
)
1605 return (REFIID
) &(pdata
->u
.mycomp
.guid
);
1608 TRACE("Unknown pidl type 0x%04x\n", pdata
->type
);
1615 /*************************************************************************
1616 * _ILGetFileDateTime
1618 * Given the ItemIdList, get the FileTime
1621 * pidl [I] The ItemIDList
1622 * pFt [I] the resulted FILETIME of the file
1625 * True if Successful
1630 BOOL
_ILGetFileDateTime(LPCITEMIDLIST pidl
, FILETIME
*pFt
)
1632 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1634 if(! pdata
) return FALSE
;
1636 switch (pdata
->type
)
1639 DosDateTimeToFileTime(pdata
->u
.folder
.uFileDate
, pdata
->u
.folder
.uFileTime
, pFt
);
1642 DosDateTimeToFileTime(pdata
->u
.file
.uFileDate
, pdata
->u
.file
.uFileTime
, pFt
);
1650 BOOL
_ILGetFileDate (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1655 if (! _ILGetFileDateTime( pidl
, &ft
)) return FALSE
;
1657 FileTimeToLocalFileTime(&ft
, &lft
);
1658 FileTimeToSystemTime (&lft
, &time
);
1659 return GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&time
, NULL
, pOut
, uOutSize
);
1662 /*************************************************************************
1665 * Given the ItemIdList, get the FileSize
1668 * pidl [I] The ItemIDList
1669 * pOut [I] The buffer to save the result
1670 * uOutsize [I] The size of the buffer
1676 * pOut can be null when no string is needed
1679 DWORD
_ILGetFileSize (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1681 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1684 if(! pdata
) return 0;
1686 switch (pdata
->type
)
1689 dwSize
= pdata
->u
.file
.dwFileSize
;
1690 if (pOut
) StrFormatByteSizeA(dwSize
, pOut
, uOutSize
);
1693 if (pOut
) *pOut
= 0x00;
1697 BOOL
_ILGetExtension (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1699 char szTemp
[MAX_PATH
];
1700 const char * pPoint
;
1701 LPITEMIDLIST pidlTemp
=pidl
;
1703 TRACE("pidl=%p\n",pidl
);
1705 if (!pidl
) return FALSE
;
1707 pidlTemp
= ILFindLastID(pidl
);
1709 if (!_ILIsValue(pidlTemp
)) return FALSE
;
1710 if (!_ILSimpleGetText(pidlTemp
, szTemp
, MAX_PATH
)) return FALSE
;
1712 pPoint
= PathFindExtensionA(szTemp
);
1714 if (! *pPoint
) return FALSE
;
1717 lstrcpynA(pOut
, pPoint
, uOutSize
);
1723 /*************************************************************************
1726 * Given the ItemIdList, get the file type description
1729 * pidl [I] The ItemIDList (simple)
1730 * pOut [I] The buffer to save the result
1731 * uOutsize [I] The size of the buffer
1737 * This function copies as much as possible into the buffer.
1739 void _ILGetFileType(LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1741 if(_ILIsValue(pidl
))
1748 if (_ILGetExtension (pidl
, sTemp
, 64))
1750 if (!( HCR_MapTypeToValue(sTemp
, sTemp
, 64, TRUE
)
1751 && HCR_MapTypeToValue(sTemp
, pOut
, uOutSize
, FALSE
)))
1753 lstrcpynA (pOut
, sTemp
, uOutSize
- 6);
1754 strcat (pOut
, "-file");
1760 lstrcpynA(pOut
, "Folder", uOutSize
);
1764 /*************************************************************************
1765 * _ILGetFileAttributes
1767 * Given the ItemIdList, get the Attrib string format
1770 * pidl [I] The ItemIDList
1771 * pOut [I] The buffer to save the result
1772 * uOutsize [I] The size of the Buffer
1778 * return value 0 in case of error is a valid return value
1781 DWORD
_ILGetFileAttributes(LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1783 LPPIDLDATA pData
=_ILGetDataPointer(pidl
);
1787 if(! pData
) return 0;
1792 wAttrib
= pData
->u
.folder
.uFileAttribs
;
1795 wAttrib
= pData
->u
.file
.uFileAttribs
;
1802 if(wAttrib
& FILE_ATTRIBUTE_READONLY
)
1806 if(wAttrib
& FILE_ATTRIBUTE_HIDDEN
)
1810 if(wAttrib
& FILE_ATTRIBUTE_SYSTEM
)
1814 if(wAttrib
& FILE_ATTRIBUTE_ARCHIVE
)
1818 if(wAttrib
& FILE_ATTRIBUTE_COMPRESSED
)
1827 /*************************************************************************
1830 * free a aPidl struct
1832 void _ILFreeaPidl(LPITEMIDLIST
* apidl
, UINT cidl
)
1838 for(i
= 0; i
< cidl
; i
++) SHFree(apidl
[i
]);
1843 /*************************************************************************
1846 * copies an aPidl struct
1848 LPITEMIDLIST
* _ILCopyaPidl(LPITEMIDLIST
* apidlsrc
, UINT cidl
)
1851 LPITEMIDLIST
* apidldest
= (LPITEMIDLIST
*)SHAlloc(cidl
* sizeof(LPITEMIDLIST
));
1852 if(!apidlsrc
) return NULL
;
1854 for(i
= 0; i
< cidl
; i
++)
1855 apidldest
[i
] = ILClone(apidlsrc
[i
]);
1860 /*************************************************************************
1861 * _ILCopyCidaToaPidl
1863 * creates aPidl from CIDA
1865 LPITEMIDLIST
* _ILCopyCidaToaPidl(LPITEMIDLIST
* pidl
, LPCIDA cida
)
1868 LPITEMIDLIST
* dst
= (LPITEMIDLIST
*)SHAlloc(cida
->cidl
* sizeof(LPITEMIDLIST
));
1870 if(!dst
) return NULL
;
1873 *pidl
= ILClone((LPITEMIDLIST
)(&((LPBYTE
)cida
)[cida
->aoffset
[0]]));
1875 for(i
= 0; i
< cida
->cidl
; i
++)
1876 dst
[i
] = ILClone((LPITEMIDLIST
)(&((LPBYTE
)cida
)[cida
->aoffset
[i
+ 1]]));