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
26 #include "wine/port.h"
36 #include "undocshell.h"
37 #include "shell32_main.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(pidl
);
46 WINE_DECLARE_DEBUG_CHANNEL(shell
);
48 /* from comctl32.dll */
49 extern LPVOID WINAPI
Alloc(INT
);
50 extern BOOL WINAPI
Free(LPVOID
);
52 /*************************************************************************
53 * ILGetDisplayNameEx [SHELL32.186]
55 * Retrieves the display name of an ItemIDList
58 * psf [I] Shell Folder to start with, if NULL the desktop is used
59 * pidl [I] ItemIDList relativ to the psf to get the display name for
60 * path [O] Filled in with the display name, assumed to be at least MAX_PATH long
61 * type [I] Type of display name to retrieve
62 * 0 = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR uses always the desktop as root
63 * 1 = SHGDN_NORMAL relative to the root folder
64 * 2 = SHGDN_INFOLDER relative to the root folder, only the last name
67 * True if the display name could be retrieved successfully, False otherwise
69 BOOL WINAPI
ILGetDisplayNameExA(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, LPSTR path
, DWORD type
)
72 WCHAR wPath
[MAX_PATH
];
74 TRACE("%p %p %p %ld\n", psf
, pidl
, path
, type
);
79 ret
= ILGetDisplayNameExW(psf
, pidl
, wPath
, type
);
80 WideCharToMultiByte(CP_ACP
, 0, wPath
, -1, path
, MAX_PATH
, NULL
, NULL
);
81 TRACE("%p %p %s\n", psf
, pidl
, debugstr_a(path
));
86 BOOL WINAPI
ILGetDisplayNameExW(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, LPWSTR path
, DWORD type
)
88 LPSHELLFOLDER psfParent
, lsf
= psf
;
89 HRESULT ret
= NO_ERROR
;
90 LPITEMIDLIST pidllast
;
94 TRACE("%p %p %p %ld\n", psf
, pidl
, path
, type
);
101 ret
= SHGetDesktopFolder(&lsf
);
106 if (type
>= 0 && type
<= 2)
110 case ILGDN_FORPARSING
:
111 flag
= SHGDN_FORPARSING
| SHGDN_FORADDRESSBAR
;
117 flag
= SHGDN_INFOLDER
;
120 FIXME("Unknown type parameter = %lx", type
);
121 flag
= SHGDN_FORPARSING
| SHGDN_FORADDRESSBAR
;
124 if (!*(LPWORD
)pidl
|| type
== ILGDN_FORPARSING
)
126 ret
= IShellFolder_GetDisplayNameOf(lsf
, pidl
, flag
, &strret
);
129 ret
= StrRetToStrNW(path
, MAX_PATH
, &strret
, pidl
);
134 ret
= SHBindToParent(pidl
, &IID_IShellFolder
, (LPVOID
*)&psfParent
, &pidllast
);
137 ret
= IShellFolder_GetDisplayNameOf(psfParent
, pidllast
, flag
, &strret
);
140 ret
= StrRetToStrNW(path
, MAX_PATH
, &strret
, pidllast
);
142 IShellFolder_Release(psfParent
);
147 TRACE("%p %p %s\n", psf
, pidl
, debugstr_w(path
));
150 IShellFolder_Release(lsf
);
151 return SUCCEEDED(ret
);
154 BOOL WINAPI
ILGetDisplayNameEx(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, LPVOID path
, DWORD type
)
156 TRACE_(shell
)("%p %p %p %ld\n", psf
, pidl
, path
, type
);
157 if (SHELL_OsIsUnicode())
158 return ILGetDisplayNameExW(psf
, pidl
, path
, type
);
159 return ILGetDisplayNameExA(psf
, pidl
, path
, type
);
162 /*************************************************************************
163 * ILGetDisplayName [SHELL32.15]
165 BOOL WINAPI
ILGetDisplayName(LPCITEMIDLIST pidl
, LPVOID path
)
167 TRACE_(shell
)("%p %p\n", pidl
, path
);
168 if (SHELL_OsIsUnicode())
169 return ILGetDisplayNameExW(NULL
, pidl
, path
, ILGDN_FORPARSING
);
170 return ILGetDisplayNameExA(NULL
, pidl
, path
, ILGDN_FORPARSING
);
173 /*************************************************************************
174 * ILFindLastID [SHELL32.16]
177 * observed: pidl=Desktop return=pidl
179 LPITEMIDLIST WINAPI
ILFindLastID(LPITEMIDLIST pidl
)
180 { LPITEMIDLIST pidlLast
= pidl
;
182 TRACE("(pidl=%p)\n",pidl
);
184 while (pidl
->mkid
.cb
)
187 pidl
= ILGetNext(pidl
);
191 /*************************************************************************
192 * ILRemoveLastID [SHELL32.17]
195 * when pidl=Desktop return=FALSE
197 BOOL WINAPI
ILRemoveLastID(LPCITEMIDLIST pidl
)
199 TRACE_(shell
)("pidl=%p\n",pidl
);
201 if (!pidl
|| !pidl
->mkid
.cb
)
203 ILFindLastID(pidl
)->mkid
.cb
= 0;
207 /*************************************************************************
208 * ILClone [SHELL32.18]
211 * duplicate an idlist
213 LPITEMIDLIST WINAPI
ILClone (LPCITEMIDLIST pidl
)
215 LPITEMIDLIST newpidl
;
220 len
= ILGetSize(pidl
);
221 newpidl
= (LPITEMIDLIST
)SHAlloc(len
);
223 memcpy(newpidl
,pidl
,len
);
225 TRACE("pidl=%p newpidl=%p\n",pidl
, newpidl
);
230 /*************************************************************************
231 * ILCloneFirst [SHELL32.19]
234 * duplicates the first idlist of a complex pidl
236 LPITEMIDLIST WINAPI
ILCloneFirst(LPCITEMIDLIST pidl
)
238 LPITEMIDLIST pidlNew
= NULL
;
240 TRACE("pidl=%p \n",pidl
);
246 pidlNew
= (LPITEMIDLIST
) SHAlloc (len
+2);
249 memcpy(pidlNew
,pidl
,len
+2); /* 2 -> mind a desktop pidl */
252 ILGetNext(pidlNew
)->mkid
.cb
= 0x00;
255 TRACE("-- newpidl=%p\n",pidlNew
);
260 /*************************************************************************
261 * ILLoadFromStream (SHELL32.26)
264 * the first two bytes are the len, the pidl is following then
266 HRESULT WINAPI
ILLoadFromStream (IStream
* pStream
, LPITEMIDLIST
* ppPidl
)
269 HRESULT ret
= E_FAIL
;
272 TRACE_(shell
)("%p %p\n", pStream
, ppPidl
);
279 IStream_AddRef (pStream
);
281 if (SUCCEEDED(IStream_Read(pStream
, (LPVOID
)&wLen
, 2, &dwBytesRead
)))
282 { *ppPidl
= SHAlloc (wLen
);
283 if (SUCCEEDED(IStream_Read(pStream
, *ppPidl
, wLen
, &dwBytesRead
)))
292 /* we are not yet fully compatible */
293 if (!pcheck(*ppPidl
))
299 IStream_Release (pStream
);
304 /*************************************************************************
305 * ILSaveToStream (SHELL32.27)
308 * the first two bytes are the len, the pidl is following then
310 HRESULT WINAPI
ILSaveToStream (IStream
* pStream
, LPCITEMIDLIST pPidl
)
314 HRESULT ret
= E_FAIL
;
316 TRACE_(shell
)("%p %p\n", pStream
, pPidl
);
318 IStream_AddRef (pStream
);
321 while (pidl
->mkid
.cb
)
323 wLen
+= sizeof(WORD
) + pidl
->mkid
.cb
;
324 pidl
= ILGetNext(pidl
);
327 if (SUCCEEDED(IStream_Write(pStream
, (LPVOID
)&wLen
, 2, NULL
)))
329 if (SUCCEEDED(IStream_Write(pStream
, pPidl
, wLen
, NULL
)))
333 IStream_Release (pStream
);
338 HRESULT WINAPI
SHILCreateFromPathA (LPCSTR path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
340 WCHAR lpszDisplayName
[MAX_PATH
];
342 HRESULT ret
= E_FAIL
;
344 TRACE_(shell
)("%s %p 0x%08lx\n",path
,ppidl
,attributes
?*attributes
:0);
346 if (!MultiByteToWideChar( CP_ACP
, 0, path
, -1, lpszDisplayName
, MAX_PATH
))
347 lpszDisplayName
[MAX_PATH
-1] = 0;
349 if (SUCCEEDED (SHGetDesktopFolder(&sf
)))
351 ret
= IShellFolder_ParseDisplayName(sf
,0, NULL
,lpszDisplayName
,&pchEaten
,ppidl
,attributes
);
352 IShellFolder_Release(sf
);
357 HRESULT WINAPI
SHILCreateFromPathW (LPCWSTR path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
360 HRESULT ret
= E_FAIL
;
362 TRACE_(shell
)("%s %p 0x%08lx\n",debugstr_w(path
),ppidl
,attributes
?*attributes
:0);
364 if (SUCCEEDED (SHGetDesktopFolder(&sf
)))
366 ret
= IShellFolder_ParseDisplayName(sf
,0, NULL
, (LPWSTR
) path
, &pchEaten
, ppidl
, attributes
);
367 IShellFolder_Release(sf
);
372 /*************************************************************************
373 * SHILCreateFromPath [SHELL32.28]
376 * Wrapper for IShellFolder_ParseDisplayName().
378 HRESULT WINAPI
SHILCreateFromPathAW (LPCVOID path
, LPITEMIDLIST
* ppidl
, DWORD
* attributes
)
380 if ( SHELL_OsIsUnicode())
381 return SHILCreateFromPathW (path
, ppidl
, attributes
);
382 return SHILCreateFromPathA (path
, ppidl
, attributes
);
385 /*************************************************************************
386 * SHCloneSpecialIDList [SHELL32.89]
390 * nFolder [in] CSIDL_xxxxx ??
395 * exported by ordinal
397 LPITEMIDLIST WINAPI
SHCloneSpecialIDList(HWND hwndOwner
,DWORD nFolder
,DWORD x3
)
398 { LPITEMIDLIST ppidl
;
399 WARN_(shell
)("(hwnd=%p,csidl=0x%lx,0x%lx):semi-stub.\n",
400 hwndOwner
,nFolder
,x3
);
402 SHGetSpecialFolderLocation(hwndOwner
, nFolder
, &ppidl
);
407 /*************************************************************************
408 * ILGlobalClone [SHELL32.20]
411 LPITEMIDLIST WINAPI
ILGlobalClone(LPCITEMIDLIST pidl
)
413 LPITEMIDLIST newpidl
;
418 len
= ILGetSize(pidl
);
419 newpidl
= (LPITEMIDLIST
)Alloc(len
);
421 memcpy(newpidl
,pidl
,len
);
423 TRACE("pidl=%p newpidl=%p\n",pidl
, newpidl
);
429 /*************************************************************************
430 * ILIsEqual [SHELL32.21]
433 BOOL WINAPI
ILIsEqual(LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
435 char szData1
[MAX_PATH
];
436 char szData2
[MAX_PATH
];
438 LPITEMIDLIST pidltemp1
= pidl1
;
439 LPITEMIDLIST pidltemp2
= pidl2
;
441 TRACE("pidl1=%p pidl2=%p\n",pidl1
, pidl2
);
443 /* explorer reads from registry directly (StreamMRU),
444 so we can only check here */
445 if ((!pcheck (pidl1
)) || (!pcheck (pidl2
))) return FALSE
;
450 if ( (!pidl1
) || (!pidl2
) ) return FALSE
;
452 while (pidltemp1
->mkid
.cb
&& pidltemp2
->mkid
.cb
)
454 _ILSimpleGetText(pidltemp1
, szData1
, MAX_PATH
);
455 _ILSimpleGetText(pidltemp2
, szData2
, MAX_PATH
);
457 if (strcasecmp ( szData1
, szData2
)!=0 )
460 pidltemp1
= ILGetNext(pidltemp1
);
461 pidltemp2
= ILGetNext(pidltemp2
);
464 if (!pidltemp1
->mkid
.cb
&& !pidltemp2
->mkid
.cb
)
471 /*************************************************************************
472 * ILIsParent [SHELL32.23]
474 * parent=a/b child=a/b/c -> true, c is in folder a/b
475 * child=a/b/c/d -> false if bImmediate is true, d is not in folder a/b
476 * child=a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b
478 BOOL WINAPI
ILIsParent( LPCITEMIDLIST pidlParent
, LPCITEMIDLIST pidlChild
, BOOL bImmediate
)
480 char szData1
[MAX_PATH
];
481 char szData2
[MAX_PATH
];
483 LPITEMIDLIST pParent
= pidlParent
;
484 LPITEMIDLIST pChild
= pidlChild
;
486 TRACE("%p %p %x\n", pidlParent
, pidlChild
, bImmediate
);
488 while (pParent
->mkid
.cb
&& pChild
->mkid
.cb
)
490 _ILSimpleGetText(pParent
, szData1
, MAX_PATH
);
491 _ILSimpleGetText(pChild
, szData2
, MAX_PATH
);
493 if (strcasecmp ( szData1
, szData2
)!=0 )
496 pParent
= ILGetNext(pParent
);
497 pChild
= ILGetNext(pChild
);
500 if ( pParent
->mkid
.cb
|| ! pChild
->mkid
.cb
) /* child shorter or has equal length to parent */
503 if ( ILGetNext(pChild
)->mkid
.cb
&& bImmediate
) /* not immediate descent */
509 /*************************************************************************
510 * ILFindChild [SHELL32.24]
513 * Compares elements from pidl1 and pidl2.
515 * pidl1 is desktop pidl2
516 * pidl1 shorter pidl2 pointer to first different element of pidl2
517 * if there was at least one equal element
518 * pidl2 shorter pidl1 0
519 * pidl2 equal pidl1 pointer to last 0x00-element of pidl2
521 LPITEMIDLIST WINAPI
ILFindChild(LPCITEMIDLIST pidl1
,LPCITEMIDLIST pidl2
)
523 char szData1
[MAX_PATH
];
524 char szData2
[MAX_PATH
];
526 LPITEMIDLIST pidltemp1
= pidl1
;
527 LPITEMIDLIST pidltemp2
= pidl2
;
528 LPITEMIDLIST ret
=NULL
;
530 TRACE("pidl1=%p pidl2=%p\n",pidl1
, pidl2
);
532 /* explorer reads from registry directly (StreamMRU),
533 so we can only check here */
534 if ((!pcheck (pidl1
)) || (!pcheck (pidl2
)))
540 if ( _ILIsDesktop(pidl1
) )
546 while (pidltemp1
->mkid
.cb
&& pidltemp2
->mkid
.cb
)
548 _ILSimpleGetText(pidltemp1
, szData1
, MAX_PATH
);
549 _ILSimpleGetText(pidltemp2
, szData2
, MAX_PATH
);
551 if (strcasecmp(szData1
,szData2
))
554 pidltemp1
= ILGetNext(pidltemp1
);
555 pidltemp2
= ILGetNext(pidltemp2
);
559 if (pidltemp1
->mkid
.cb
)
561 ret
= NULL
; /* elements of pidl1 left*/
564 TRACE_(shell
)("--- %p\n", ret
);
565 return ret
; /* pidl 1 is shorter */
568 /*************************************************************************
569 * ILCombine [SHELL32.25]
572 * Concatenates two complex idlists.
573 * The pidl is the first one, pidlsub the next one
574 * Does not destroy the passed in idlists!
576 LPITEMIDLIST WINAPI
ILCombine(LPCITEMIDLIST pidl1
,LPCITEMIDLIST pidl2
)
579 LPITEMIDLIST pidlNew
;
581 TRACE("pidl=%p pidl=%p\n",pidl1
,pidl2
);
583 if(!pidl1
&& !pidl2
) return NULL
;
590 pidlNew
= ILClone(pidl2
);
596 pidlNew
= ILClone(pidl1
);
600 len1
= ILGetSize(pidl1
)-2;
601 len2
= ILGetSize(pidl2
);
602 pidlNew
= SHAlloc(len1
+len2
);
606 memcpy(pidlNew
,pidl1
,len1
);
607 memcpy(((BYTE
*)pidlNew
)+len1
,pidl2
,len2
);
610 /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/
613 /*************************************************************************
614 * SHGetRealIDL [SHELL32.98]
618 LPITEMIDLIST WINAPI
SHGetRealIDL(LPSHELLFOLDER lpsf
, LPITEMIDLIST pidl
, DWORD z
)
620 FIXME("sf=%p pidl=%p 0x%04lx\n",lpsf
,pidl
,z
);
626 /*************************************************************************
627 * SHLogILFromFSIL [SHELL32.95]
630 * pild = CSIDL_DESKTOP ret = 0
631 * pild = CSIDL_DRIVES ret = 0
633 LPITEMIDLIST WINAPI
SHLogILFromFSIL(LPITEMIDLIST pidl
)
635 FIXME("(pidl=%p)\n",pidl
);
642 /*************************************************************************
643 * ILGetSize [SHELL32.152]
644 * gets the byte size of an idlist including zero terminator (pidl)
653 * exported by ordinal
655 DWORD WINAPI
ILGetSize(LPITEMIDLIST pidl
)
657 LPSHITEMID si
= &(pidl
->mkid
);
663 si
= (LPSHITEMID
)(((LPBYTE
)si
)+si
->cb
);
667 TRACE("pidl=%p size=%lu\n",pidl
, len
);
671 /*************************************************************************
672 * ILGetNext [SHELL32.153]
673 * gets the next simple pidl of a complex pidl
675 * observed return values:
678 * simple pidl -> pointer to 0x0000 element
681 LPITEMIDLIST WINAPI
ILGetNext(LPITEMIDLIST pidl
)
692 pidl
= (LPITEMIDLIST
) (((LPBYTE
)pidl
)+len
);
693 TRACE("-- %p\n", pidl
);
699 /*************************************************************************
700 * ILAppend [SHELL32.154]
703 * Adds the single item to the idlist indicated by pidl.
704 * if bEnd is 0, adds the item to the front of the list,
705 * otherwise adds the item to the end. (???)
706 * Destroys the passed in idlist! (???)
708 LPITEMIDLIST WINAPI
ILAppend(LPITEMIDLIST pidl
,LPCITEMIDLIST item
,BOOL bEnd
)
712 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl
,item
,bEnd
);
717 if (_ILIsDesktop(pidl
))
719 idlRet
= ILClone(item
);
727 idlRet
=ILCombine(pidl
,item
);
731 idlRet
=ILCombine(item
,pidl
);
737 /*************************************************************************
738 * ILFree [SHELL32.155]
741 * free_check_ptr - frees memory (if not NULL)
742 * allocated by SHMalloc allocator
743 * exported by ordinal
745 DWORD WINAPI
ILFree(LPITEMIDLIST pidl
)
747 TRACE("(pidl=0x%08lx)\n",(DWORD
)pidl
);
749 if(!pidl
) return FALSE
;
753 /*************************************************************************
754 * ILGlobalFree [SHELL32.156]
757 void WINAPI
ILGlobalFree( LPCITEMIDLIST pidl
)
764 /*************************************************************************
765 * ILCreateFromPath [SHELL32.157]
768 LPITEMIDLIST WINAPI
ILCreateFromPathA (LPCSTR path
)
770 LPITEMIDLIST pidlnew
;
771 DWORD attributes
= 0;
773 TRACE_(shell
)("%s\n",path
);
775 if (SUCCEEDED (SHILCreateFromPathA (path
, &pidlnew
, &attributes
)))
779 LPITEMIDLIST WINAPI
ILCreateFromPathW (LPCWSTR path
)
781 LPITEMIDLIST pidlnew
;
782 DWORD attributes
= 0;
784 TRACE_(shell
)("%s\n",debugstr_w(path
));
786 if (SUCCEEDED (SHILCreateFromPathW (path
, &pidlnew
, &attributes
)))
790 LPITEMIDLIST WINAPI
ILCreateFromPathAW (LPCVOID path
)
792 if ( SHELL_OsIsUnicode())
793 return ILCreateFromPathW (path
);
794 return ILCreateFromPathA (path
);
796 /*************************************************************************
797 * SHSimpleIDListFromPath [SHELL32.162]
799 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathA (LPCSTR lpszPath
)
801 LPITEMIDLIST pidl
=NULL
;
803 WIN32_FIND_DATAA stffile
;
805 TRACE("path=%s\n", lpszPath
);
807 if (!lpszPath
) return NULL
;
809 hFile
= FindFirstFileA(lpszPath
, &stffile
);
811 if ( hFile
!= INVALID_HANDLE_VALUE
)
813 if (stffile
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
815 pidl
= _ILCreateFolder (&stffile
);
819 pidl
= _ILCreateValue (&stffile
);
825 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathW (LPCWSTR lpszPath
)
827 char lpszTemp
[MAX_PATH
];
828 TRACE("path=%s\n",debugstr_w(lpszPath
));
830 if (!WideCharToMultiByte( CP_ACP
, 0, lpszPath
, -1, lpszTemp
, sizeof(lpszTemp
), NULL
, NULL
))
831 lpszTemp
[sizeof(lpszTemp
)-1] = 0;
833 return SHSimpleIDListFromPathA (lpszTemp
);
836 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathAW (LPCVOID lpszPath
)
838 if ( SHELL_OsIsUnicode())
839 return SHSimpleIDListFromPathW (lpszPath
);
840 return SHSimpleIDListFromPathA (lpszPath
);
843 /*************************************************************************
844 * SHGetSpecialFolderLocation [SHELL32.@]
846 * gets the folder locations from the registry and creates a pidl
847 * creates missing reg keys and directories
851 * nFolder [I] CSIDL_xxxxx
852 * ppidl [O] PIDL of a special folder
855 HRESULT WINAPI
SHGetSpecialFolderLocation(
858 LPITEMIDLIST
* ppidl
)
860 CHAR szPath
[MAX_PATH
];
861 HRESULT hr
= E_INVALIDARG
;
863 TRACE_(shell
)("(%p,0x%x,%p)\n", hwndOwner
,nFolder
,ppidl
);
871 *ppidl
= _ILCreateDesktop();
875 *ppidl
= _ILCreateMyComputer();
879 *ppidl
= _ILCreateNetwork ();
883 *ppidl
= _ILCreateControl ();
887 *ppidl
= _ILCreatePrinter ();
890 case CSIDL_BITBUCKET
:
891 *ppidl
= _ILCreateBitBucket ();
895 if (SHGetSpecialFolderPathA(hwndOwner
, szPath
, nFolder
, TRUE
))
898 TRACE_(shell
)("Value=%s\n",szPath
);
899 hr
= SHILCreateFromPathA(szPath
, ppidl
, &attributes
);
902 if(*ppidl
) hr
= NOERROR
;
905 TRACE_(shell
)("-- (new pidl %p)\n",*ppidl
);
909 /*************************************************************************
910 * SHGetFolderLocation [SHELL32.@]
913 * the pidl can be a simple one. since we cant get the path out of the pidl
914 * we have to take all data from the pidl
916 HRESULT WINAPI
SHGetFolderLocation(
923 FIXME("%p 0x%08x %p 0x%08lx %p\n",
924 hwnd
, csidl
, hToken
, dwFlags
, ppidl
);
925 return SHGetSpecialFolderLocation(hwnd
, csidl
, ppidl
);
928 /*************************************************************************
929 * SHGetDataFromIDListA [SHELL32.247]
932 * the pidl can be a simple one. since we cant get the path out of the pidl
933 * we have to take all data from the pidl
935 HRESULT WINAPI
SHGetDataFromIDListA(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, int nFormat
, LPVOID dest
, int len
)
937 TRACE_(shell
)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf
,pidl
,nFormat
,dest
,len
);
940 if (!psf
|| !dest
) return E_INVALIDARG
;
944 case SHGDFIL_FINDDATA
:
946 WIN32_FIND_DATAA
* pfd
= dest
;
948 if ( len
< sizeof (WIN32_FIND_DATAA
)) return E_INVALIDARG
;
950 ZeroMemory(pfd
, sizeof (WIN32_FIND_DATAA
));
951 _ILGetFileDateTime( pidl
, &(pfd
->ftLastWriteTime
));
952 pfd
->dwFileAttributes
= _ILGetFileAttributes(pidl
, NULL
, 0);
953 pfd
->nFileSizeLow
= _ILGetFileSize ( pidl
, NULL
, 0);
954 lstrcpynA(pfd
->cFileName
,_ILGetTextPointer(pidl
), MAX_PATH
);
955 lstrcpynA(pfd
->cAlternateFileName
,_ILGetSTextPointer(pidl
), 14);
959 case SHGDFIL_NETRESOURCE
:
960 case SHGDFIL_DESCRIPTIONID
:
961 FIXME_(shell
)("SHGDFIL %i stub\n", nFormat
);
965 ERR_(shell
)("Unknown SHGDFIL %i, please report\n", nFormat
);
970 /*************************************************************************
971 * SHGetDataFromIDListW [SHELL32.248]
974 HRESULT WINAPI
SHGetDataFromIDListW(LPSHELLFOLDER psf
, LPCITEMIDLIST pidl
, int nFormat
, LPVOID dest
, int len
)
976 TRACE_(shell
)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf
,pidl
,nFormat
,dest
,len
);
980 if (! psf
|| !dest
) return E_INVALIDARG
;
984 case SHGDFIL_FINDDATA
:
986 WIN32_FIND_DATAW
* pfd
= dest
;
988 if ( len
< sizeof (WIN32_FIND_DATAW
)) return E_INVALIDARG
;
990 ZeroMemory(pfd
, sizeof (WIN32_FIND_DATAA
));
991 _ILGetFileDateTime( pidl
, &(pfd
->ftLastWriteTime
));
992 pfd
->dwFileAttributes
= _ILGetFileAttributes(pidl
, NULL
, 0);
993 pfd
->nFileSizeLow
= _ILGetFileSize ( pidl
, NULL
, 0);
994 if (!MultiByteToWideChar( CP_ACP
, 0, _ILGetTextPointer(pidl
), -1,
995 pfd
->cFileName
, MAX_PATH
))
996 pfd
->cFileName
[MAX_PATH
-1] = 0;
997 if (!MultiByteToWideChar( CP_ACP
, 0, _ILGetSTextPointer(pidl
), -1,
998 pfd
->cAlternateFileName
, 14 ))
999 pfd
->cFileName
[13] = 0;
1002 case SHGDFIL_NETRESOURCE
:
1003 case SHGDFIL_DESCRIPTIONID
:
1004 FIXME_(shell
)("SHGDFIL %i stub\n", nFormat
);
1008 ERR_(shell
)("Unknown SHGDFIL %i, please report\n", nFormat
);
1011 return E_INVALIDARG
;
1014 /*************************************************************************
1015 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
1019 * pszPath [OUT] path
1022 * path from a passed PIDL.
1025 * NULL returns FALSE
1026 * desktop pidl gives path to desktopdirectory back
1027 * special pidls returning FALSE
1029 BOOL WINAPI
SHGetPathFromIDListA(LPCITEMIDLIST pidl
, LPSTR pszPath
)
1033 LPSHELLFOLDER shellfolder
;
1035 TRACE_(shell
)("(pidl=%p,%p)\n",pidl
,pszPath
);
1038 if (!pidl
) return FALSE
;
1040 hr
= SHGetDesktopFolder(&shellfolder
);
1041 if (SUCCEEDED (hr
)) {
1042 hr
= IShellFolder_GetDisplayNameOf(shellfolder
,pidl
,SHGDN_FORPARSING
,&str
);
1044 StrRetToStrNA (pszPath
, MAX_PATH
, &str
, pidl
);
1046 IShellFolder_Release(shellfolder
);
1049 TRACE_(shell
)("-- %s, 0x%08lx\n",pszPath
, hr
);
1050 return SUCCEEDED(hr
);
1052 /*************************************************************************
1053 * SHGetPathFromIDListW [SHELL32.@]
1055 BOOL WINAPI
SHGetPathFromIDListW(LPCITEMIDLIST pidl
, LPWSTR pszPath
)
1059 LPSHELLFOLDER shellfolder
;
1061 TRACE_(shell
)("(pidl=%p,%p)\n", pidl
, debugstr_w(pszPath
));
1064 if (!pidl
) return FALSE
;
1066 hr
= SHGetDesktopFolder(&shellfolder
);
1067 if (SUCCEEDED(hr
)) {
1068 hr
= IShellFolder_GetDisplayNameOf(shellfolder
, pidl
, SHGDN_FORPARSING
, &str
);
1069 if (SUCCEEDED(hr
)) {
1070 StrRetToStrNW(pszPath
, MAX_PATH
, &str
, pidl
);
1072 IShellFolder_Release(shellfolder
);
1075 TRACE_(shell
)("-- %s, 0x%08lx\n",debugstr_w(pszPath
), hr
);
1076 return SUCCEEDED(hr
);
1079 /*************************************************************************
1080 * SHBindToParent [shell version 5.0]
1082 HRESULT WINAPI
SHBindToParent(LPCITEMIDLIST pidl
, REFIID riid
, LPVOID
*ppv
, LPCITEMIDLIST
*ppidlLast
)
1085 LPITEMIDLIST pidlChild
, pidlParent
;
1088 TRACE_(shell
)("pidl=%p\n", pidl
);
1092 if (ppidlLast
) *ppidlLast
= NULL
;
1094 if (_ILIsPidlSimple(pidl
))
1096 /* we are on desktop level */
1098 *ppidlLast
= ILClone(pidl
);
1099 hr
= SHGetDesktopFolder((IShellFolder
**)ppv
);
1103 pidlChild
= ILClone(ILFindLastID(pidl
));
1104 pidlParent
= ILClone(pidl
);
1105 ILRemoveLastID(pidlParent
);
1107 hr
= SHGetDesktopFolder(&psf
);
1110 hr
= IShellFolder_BindToObject(psf
, pidlParent
, NULL
, riid
, ppv
);
1112 if (SUCCEEDED(hr
) && ppidlLast
)
1113 *ppidlLast
= pidlChild
;
1117 SHFree (pidlParent
);
1118 if (psf
) IShellFolder_Release(psf
);
1122 TRACE_(shell
)("-- psf=%p pidl=%p ret=0x%08lx\n", *ppv
, (ppidlLast
)?*ppidlLast
:NULL
, hr
);
1126 /*************************************************************************
1127 * SHGetPathFromIDList [SHELL32.@][NT 4.0: SHELL32.219]
1129 BOOL WINAPI
SHGetPathFromIDListAW(LPCITEMIDLIST pidl
,LPVOID pszPath
)
1131 TRACE_(shell
)("(pidl=%p,%p)\n",pidl
,pszPath
);
1133 if (SHELL_OsIsUnicode())
1134 return SHGetPathFromIDListW(pidl
,pszPath
);
1135 return SHGetPathFromIDListA(pidl
,pszPath
);
1138 /**************************************************************************
1140 * internal functions
1142 * ### 1. section creating pidls ###
1144 *************************************************************************
1145 * _ILCreateDesktop()
1146 * _ILCreateIExplore()
1147 * _ILCreateMyComputer()
1152 LPITEMIDLIST
_ILCreateDesktop()
1154 return _ILCreate(PT_DESKTOP
, NULL
, 0);
1157 LPITEMIDLIST
_ILCreateMyComputer()
1159 return _ILCreate(PT_MYCOMP
, &CLSID_MyComputer
, sizeof(GUID
));
1162 LPITEMIDLIST
_ILCreateIExplore()
1164 return _ILCreate(PT_MYCOMP
, &CLSID_Internet
, sizeof(GUID
));
1167 LPITEMIDLIST
_ILCreateControl()
1169 return _ILCreate(PT_SPECIAL
, &CLSID_ControlPanel
, sizeof(GUID
));
1172 LPITEMIDLIST
_ILCreatePrinter()
1174 return _ILCreate(PT_SPECIAL
, &CLSID_Printers
, sizeof(GUID
));
1177 LPITEMIDLIST
_ILCreateNetwork()
1179 return _ILCreate(PT_MYCOMP
, &CLSID_NetworkPlaces
, sizeof(GUID
));
1182 LPITEMIDLIST
_ILCreateBitBucket()
1184 return _ILCreate(PT_MYCOMP
, &CLSID_RecycleBin
, sizeof(GUID
));
1187 LPITEMIDLIST
_ILCreateDrive( LPCSTR lpszNew
)
1189 lstrcpynA (sTemp
,lpszNew
,4);
1192 TRACE("(%s)\n",sTemp
);
1193 return _ILCreate(PT_DRIVE
,(LPVOID
)&sTemp
[0],4);
1196 LPITEMIDLIST
_ILCreateFolder( WIN32_FIND_DATAA
* stffile
)
1198 char buff
[MAX_PATH
+ 14 +1]; /* see WIN32_FIND_DATA */
1199 char * pbuff
= buff
;
1203 TRACE("(%s, %s)\n",stffile
->cAlternateFileName
, stffile
->cFileName
);
1205 /* prepare buffer with both names */
1206 len
= strlen (stffile
->cFileName
) + 1;
1207 memcpy (pbuff
, stffile
->cFileName
, len
);
1210 if (stffile
->cAlternateFileName
)
1212 len1
= strlen (stffile
->cAlternateFileName
)+1;
1213 memcpy (pbuff
, stffile
->cAlternateFileName
, len1
);
1221 pidl
= _ILCreate(PT_FOLDER
, (LPVOID
)buff
, len
+ len1
);
1223 /* set attributes */
1227 pData
= _ILGetDataPointer(pidl
);
1228 FileTimeToDosDateTime(&(stffile
->ftLastWriteTime
),&pData
->u
.folder
.uFileDate
,&pData
->u
.folder
.uFileTime
);
1229 pData
->u
.folder
.dwFileSize
= stffile
->nFileSizeLow
;
1230 pData
->u
.folder
.uFileAttribs
= stffile
->dwFileAttributes
;
1236 LPITEMIDLIST
_ILCreateValue(WIN32_FIND_DATAA
* stffile
)
1238 char buff
[MAX_PATH
+ 14 +1]; /* see WIN32_FIND_DATA */
1239 char * pbuff
= buff
;
1243 TRACE("(%s, %s)\n",stffile
->cAlternateFileName
, stffile
->cFileName
);
1245 /* prepare buffer with both names */
1246 len
= strlen (stffile
->cFileName
) + 1;
1247 memcpy (pbuff
, stffile
->cFileName
, len
);
1250 if (stffile
->cAlternateFileName
)
1252 len1
= strlen (stffile
->cAlternateFileName
)+1;
1253 memcpy (pbuff
, stffile
->cAlternateFileName
, len1
);
1261 pidl
= _ILCreate(PT_VALUE
, (LPVOID
)buff
, len
+ len1
);
1263 /* set attributes */
1267 pData
= _ILGetDataPointer(pidl
);
1268 FileTimeToDosDateTime(&(stffile
->ftLastWriteTime
),&pData
->u
.folder
.uFileDate
,&pData
->u
.folder
.uFileTime
);
1269 pData
->u
.folder
.dwFileSize
= stffile
->nFileSizeLow
;
1270 pData
->u
.folder
.uFileAttribs
=stffile
->dwFileAttributes
;
1276 LPITEMIDLIST
_ILCreateFromPathA(LPCSTR szPath
)
1279 WIN32_FIND_DATAA stffile
;
1280 LPITEMIDLIST pidl
= NULL
;
1282 hFile
= FindFirstFileA(szPath
, &stffile
);
1283 if (hFile
!= INVALID_HANDLE_VALUE
)
1285 if (stffile
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
1286 pidl
= _ILCreateFolder(&stffile
);
1288 pidl
= _ILCreateValue(&stffile
);
1294 LPITEMIDLIST
_ILCreateSpecial(LPCSTR szGUID
)
1298 if (!SUCCEEDED(SHCLSIDFromStringA(szGUID
, &iid
)))
1300 ERR("%s is not a GUID\n", szGUID
);
1303 return _ILCreate(PT_MYCOMP
, &iid
, sizeof(IID
));
1306 /**************************************************************************
1308 * Creates a new PIDL
1309 * type = PT_DESKTOP | PT_DRIVE | PT_FOLDER | PT_VALUE
1311 * uInSize = size of data (raw)
1314 LPITEMIDLIST
_ILCreate(PIDLTYPE type
, LPCVOID pIn
, UINT uInSize
)
1316 LPITEMIDLIST pidlOut
= NULL
, pidlTemp
= NULL
;
1321 TRACE("(0x%02x %p %i)\n",type
,pIn
,uInSize
);
1330 uSize
= 2 + 2 + sizeof(GUID
);
1337 uSize
= 2 + 12 + uInSize
;
1340 FIXME("can't create type: 0x%08x\n",type
);
1344 if(!(pidlOut
= SHAlloc(uSize
+ 2))) return NULL
;
1345 ZeroMemory(pidlOut
, uSize
+ 2);
1346 pidlOut
->mkid
.cb
= uSize
;
1351 TRACE("- create Desktop\n");
1356 pData
=_ILGetDataPointer(pidlOut
);
1358 memcpy(&(pData
->u
.mycomp
.guid
), pIn
, uInSize
);
1359 TRACE("-- create GUID-pidl %s\n", debugstr_guid(&(pData
->u
.mycomp
.guid
)));
1363 pData
=_ILGetDataPointer(pidlOut
);
1365 pszDest
= _ILGetTextPointer(pidlOut
);
1366 memcpy(pszDest
, pIn
, uInSize
);
1367 TRACE("-- create Drive: %s\n",debugstr_a(pszDest
));
1372 pData
=_ILGetDataPointer(pidlOut
);
1374 pszDest
= _ILGetTextPointer(pidlOut
);
1375 memcpy(pszDest
, pIn
, uInSize
);
1376 TRACE("-- create Value: %s\n",debugstr_a(pszDest
));
1380 pidlTemp
= ILGetNext(pidlOut
);
1382 pidlTemp
->mkid
.cb
= 0x00;
1384 TRACE("-- (pidl=%p, size=%u)\n", pidlOut
, uSize
);
1388 /**************************************************************************
1391 * Gets the text for the drive eg. 'c:\'
1396 DWORD
_ILGetDrive(LPCITEMIDLIST pidl
,LPSTR pOut
, UINT uSize
)
1397 { TRACE("(%p,%p,%u)\n",pidl
,pOut
,uSize
);
1399 if(_ILIsMyComputer(pidl
))
1400 pidl
= ILGetNext(pidl
);
1402 if (pidl
&& _ILIsDrive(pidl
))
1403 return _ILSimpleGetText(pidl
, pOut
, uSize
);
1408 /**************************************************************************
1410 * ### 2. section testing pidls ###
1412 **************************************************************************
1415 * _ILIsSpecialFolder()
1421 BOOL
_ILIsDesktop(LPCITEMIDLIST pidl
)
1422 { TRACE("(%p)\n",pidl
);
1423 return pidl
&& pidl
->mkid
.cb
? 0 : 1;
1426 BOOL
_ILIsMyComputer(LPCITEMIDLIST pidl
)
1428 REFIID iid
= _ILGetGUIDPointer(pidl
);
1430 TRACE("(%p)\n",pidl
);
1433 return IsEqualIID(iid
, &CLSID_MyComputer
);
1437 BOOL
_ILIsSpecialFolder (LPCITEMIDLIST pidl
)
1439 LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1440 TRACE("(%p)\n",pidl
);
1441 return (pidl
&& ( (lpPData
&& (PT_MYCOMP
== lpPData
->type
|| PT_SPECIAL
== lpPData
->type
)) ||
1442 (pidl
&& pidl
->mkid
.cb
== 0x00)
1446 BOOL
_ILIsDrive(LPCITEMIDLIST pidl
)
1447 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1448 TRACE("(%p)\n",pidl
);
1449 return (pidl
&& lpPData
&& (PT_DRIVE
== lpPData
->type
||
1450 PT_DRIVE1
== lpPData
->type
||
1451 PT_DRIVE2
== lpPData
->type
||
1452 PT_DRIVE3
== lpPData
->type
));
1455 BOOL
_ILIsFolder(LPCITEMIDLIST pidl
)
1456 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1457 TRACE("(%p)\n",pidl
);
1458 return (pidl
&& lpPData
&& (PT_FOLDER
== lpPData
->type
|| PT_FOLDER1
== lpPData
->type
));
1461 BOOL
_ILIsValue(LPCITEMIDLIST pidl
)
1462 { LPPIDLDATA lpPData
= _ILGetDataPointer(pidl
);
1463 TRACE("(%p)\n",pidl
);
1464 return (pidl
&& lpPData
&& PT_VALUE
== lpPData
->type
);
1467 /**************************************************************************
1470 BOOL
_ILIsPidlSimple ( LPCITEMIDLIST pidl
)
1474 if(! _ILIsDesktop(pidl
)) /* pidl=NULL or mkid.cb=0 */
1476 WORD len
= pidl
->mkid
.cb
;
1477 LPCITEMIDLIST pidlnext
= (LPCITEMIDLIST
) (((LPBYTE
)pidl
) + len
);
1478 if (pidlnext
->mkid
.cb
)
1482 TRACE("%s\n", ret
? "Yes" : "No");
1486 /**************************************************************************
1488 * ### 3. section getting values from pidls ###
1491 /**************************************************************************
1494 * gets the text for the first item in the pidl (eg. simple pidl)
1496 * returns the length of the string
1498 DWORD
_ILSimpleGetText (LPCITEMIDLIST pidl
, LPSTR szOut
, UINT uOutSize
)
1503 char szTemp
[MAX_PATH
];
1505 TRACE("(%p %p %x)\n",pidl
,szOut
,uOutSize
);
1507 if (!pidl
) return 0;
1512 if (_ILIsDesktop(pidl
))
1515 if (HCR_GetClassNameA(&CLSID_ShellDesktop
, szTemp
, MAX_PATH
))
1518 lstrcpynA(szOut
, szTemp
, uOutSize
);
1520 dwReturn
= strlen (szTemp
);
1523 else if (( szSrc
= _ILGetTextPointer(pidl
) ))
1527 lstrcpynA(szOut
, szSrc
, uOutSize
);
1529 dwReturn
= strlen(szSrc
);
1531 else if (( riid
= _ILGetGUIDPointer(pidl
) ))
1533 /* special folder */
1534 if ( HCR_GetClassNameA(riid
, szTemp
, MAX_PATH
) )
1537 lstrcpynA(szOut
, szTemp
, uOutSize
);
1539 dwReturn
= strlen (szTemp
);
1544 ERR("-- no text\n");
1547 TRACE("-- (%p=%s 0x%08lx)\n",szOut
,debugstr_a(szOut
),dwReturn
);
1551 /**************************************************************************
1553 * ### 4. getting pointers to parts of pidls ###
1555 **************************************************************************
1556 * _ILGetDataPointer()
1558 LPPIDLDATA
_ILGetDataPointer(LPITEMIDLIST pidl
)
1560 if(pidl
&& pidl
->mkid
.cb
!= 0x00)
1561 return (LPPIDLDATA
) &(pidl
->mkid
.abID
);
1565 /**************************************************************************
1566 * _ILGetTextPointer()
1567 * gets a pointer to the long filename string stored in the pidl
1569 LPSTR
_ILGetTextPointer(LPCITEMIDLIST pidl
)
1570 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1572 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1576 switch (pdata
->type
)
1586 return (LPSTR
)&(pdata
->u
.drive
.szDriveName
);
1593 return (LPSTR
)&(pdata
->u
.file
.szNames
);
1598 case PT_NETPROVIDER
:
1600 return (LPSTR
)&(pdata
->u
.network
.szNames
);
1606 /**************************************************************************
1607 * _ILGetSTextPointer()
1608 * gets a pointer to the short filename string stored in the pidl
1610 LPSTR
_ILGetSTextPointer(LPCITEMIDLIST pidl
)
1611 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1613 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1617 switch (pdata
->type
)
1623 return (LPSTR
)(pdata
->u
.file
.szNames
+ strlen (pdata
->u
.file
.szNames
) + 1);
1626 return (LPSTR
)(pdata
->u
.network
.szNames
+ strlen (pdata
->u
.network
.szNames
) + 1);
1632 /**************************************************************************
1633 * _ILGetGUIDPointer()
1635 * returns reference to guid stored in some pidls
1637 REFIID
_ILGetGUIDPointer(LPCITEMIDLIST pidl
)
1639 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1641 TRACE("%p\n", pidl
);
1645 TRACE("pdata->type 0x%04x\n", pdata
->type
);
1646 switch (pdata
->type
)
1650 return (REFIID
) &(pdata
->u
.mycomp
.guid
);
1653 TRACE("Unknown pidl type 0x%04x\n", pdata
->type
);
1660 /*************************************************************************
1661 * _ILGetFileDateTime
1663 * Given the ItemIdList, get the FileTime
1666 * pidl [I] The ItemIDList
1667 * pFt [I] the resulted FILETIME of the file
1670 * True if Successful
1675 BOOL
_ILGetFileDateTime(LPCITEMIDLIST pidl
, FILETIME
*pFt
)
1677 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1679 if(! pdata
) return FALSE
;
1681 switch (pdata
->type
)
1684 DosDateTimeToFileTime(pdata
->u
.folder
.uFileDate
, pdata
->u
.folder
.uFileTime
, pFt
);
1687 DosDateTimeToFileTime(pdata
->u
.file
.uFileDate
, pdata
->u
.file
.uFileTime
, pFt
);
1695 BOOL
_ILGetFileDate (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1701 if (_ILGetFileDateTime( pidl
, &ft
)) {
1702 FileTimeToLocalFileTime(&ft
, &lft
);
1703 FileTimeToSystemTime (&lft
, &time
);
1704 ret
= GetDateFormatA(LOCALE_USER_DEFAULT
,DATE_SHORTDATE
,&time
, NULL
, pOut
, uOutSize
);
1713 /*************************************************************************
1716 * Given the ItemIdList, get the FileSize
1719 * pidl [I] The ItemIDList
1720 * pOut [I] The buffer to save the result
1721 * uOutsize [I] The size of the buffer
1727 * pOut can be null when no string is needed
1730 DWORD
_ILGetFileSize (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1732 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
1735 if(! pdata
) return 0;
1737 switch (pdata
->type
)
1740 dwSize
= pdata
->u
.file
.dwFileSize
;
1741 if (pOut
) StrFormatByteSizeA(dwSize
, pOut
, uOutSize
);
1744 if (pOut
) *pOut
= 0x00;
1748 BOOL
_ILGetExtension (LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1750 char szTemp
[MAX_PATH
];
1751 const char * pPoint
;
1752 LPITEMIDLIST pidlTemp
=pidl
;
1754 TRACE("pidl=%p\n",pidl
);
1756 if (!pidl
) return FALSE
;
1758 pidlTemp
= ILFindLastID(pidl
);
1760 if (!_ILIsValue(pidlTemp
)) return FALSE
;
1761 if (!_ILSimpleGetText(pidlTemp
, szTemp
, MAX_PATH
)) return FALSE
;
1763 pPoint
= PathFindExtensionA(szTemp
);
1765 if (! *pPoint
) return FALSE
;
1768 lstrcpynA(pOut
, pPoint
, uOutSize
);
1774 /*************************************************************************
1777 * Given the ItemIdList, get the file type description
1780 * pidl [I] The ItemIDList (simple)
1781 * pOut [I] The buffer to save the result
1782 * uOutsize [I] The size of the buffer
1788 * This function copies as much as possible into the buffer.
1790 void _ILGetFileType(LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1792 if(_ILIsValue(pidl
))
1799 if (_ILGetExtension (pidl
, sTemp
, 64))
1801 if (!( HCR_MapTypeToValueA(sTemp
, sTemp
, 64, TRUE
)
1802 && HCR_MapTypeToValueA(sTemp
, pOut
, uOutSize
, FALSE
)))
1804 lstrcpynA (pOut
, sTemp
, uOutSize
- 6);
1805 strcat (pOut
, "-file");
1811 lstrcpynA(pOut
, "Folder", uOutSize
);
1815 /*************************************************************************
1816 * _ILGetFileAttributes
1818 * Given the ItemIdList, get the Attrib string format
1821 * pidl [I] The ItemIDList
1822 * pOut [I] The buffer to save the result
1823 * uOutsize [I] The size of the Buffer
1829 * return value 0 in case of error is a valid return value
1832 DWORD
_ILGetFileAttributes(LPCITEMIDLIST pidl
, LPSTR pOut
, UINT uOutSize
)
1834 LPPIDLDATA pData
=_ILGetDataPointer(pidl
);
1838 if(! pData
) return 0;
1843 wAttrib
= pData
->u
.folder
.uFileAttribs
;
1846 wAttrib
= pData
->u
.file
.uFileAttribs
;
1853 if(wAttrib
& FILE_ATTRIBUTE_READONLY
)
1857 if(wAttrib
& FILE_ATTRIBUTE_HIDDEN
)
1861 if(wAttrib
& FILE_ATTRIBUTE_SYSTEM
)
1865 if(wAttrib
& FILE_ATTRIBUTE_ARCHIVE
)
1869 if(wAttrib
& FILE_ATTRIBUTE_COMPRESSED
)
1878 /*************************************************************************
1881 * free a aPidl struct
1883 void _ILFreeaPidl(LPITEMIDLIST
* apidl
, UINT cidl
)
1889 for (i
= 0; i
< cidl
; i
++) SHFree(apidl
[i
]);
1894 /*************************************************************************
1897 * copies an aPidl struct
1899 LPITEMIDLIST
* _ILCopyaPidl(LPITEMIDLIST
* apidlsrc
, UINT cidl
)
1902 LPITEMIDLIST
* apidldest
= (LPITEMIDLIST
*)SHAlloc(cidl
* sizeof(LPITEMIDLIST
));
1903 if(!apidlsrc
) return NULL
;
1905 for (i
= 0; i
< cidl
; i
++)
1906 apidldest
[i
] = ILClone(apidlsrc
[i
]);
1911 /*************************************************************************
1912 * _ILCopyCidaToaPidl
1914 * creates aPidl from CIDA
1916 LPITEMIDLIST
* _ILCopyCidaToaPidl(LPITEMIDLIST
* pidl
, LPIDA cida
)
1919 LPITEMIDLIST
* dst
= (LPITEMIDLIST
*)SHAlloc(cida
->cidl
* sizeof(LPITEMIDLIST
));
1921 if(!dst
) return NULL
;
1924 *pidl
= ILClone((LPITEMIDLIST
)(&((LPBYTE
)cida
)[cida
->aoffset
[0]]));
1926 for (i
= 0; i
< cida
->cidl
; i
++)
1927 dst
[i
] = ILClone((LPITEMIDLIST
)(&((LPBYTE
)cida
)[cida
->aoffset
[i
+ 1]]));