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 LPCITEMIDLIST 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(LPCITEMIDLIST pidl)
180 { LPCITEMIDLIST pidlLast = pidl;
182 TRACE("(pidl=%p)\n",pidl);
184 while (pidl->mkid.cb)
187 pidl = ILGetNext(pidl);
189 return (LPITEMIDLIST)pidlLast;
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)))
283 TRACE("PIDL length is %d\n", wLen);
285 *ppPidl = SHAlloc (wLen);
286 if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead))) {
287 TRACE("Stream read OK\n");
290 WARN("reading pidl failed\n");
300 /* we are not yet fully compatible */
301 if (*ppPidl && !pcheck(*ppPidl))
303 WARN("Check failed\n");
309 IStream_Release (pStream);
314 /*************************************************************************
315 * ILSaveToStream (SHELL32.27)
318 * the first two bytes are the len, the pidl is following then
320 HRESULT WINAPI ILSaveToStream (IStream * pStream, LPCITEMIDLIST pPidl)
324 HRESULT ret = E_FAIL;
326 TRACE_(shell)("%p %p\n", pStream, pPidl);
328 IStream_AddRef (pStream);
331 while (pidl->mkid.cb)
333 wLen += sizeof(WORD) + pidl->mkid.cb;
334 pidl = ILGetNext(pidl);
337 if (SUCCEEDED(IStream_Write(pStream, (LPVOID)&wLen, 2, NULL)))
339 if (SUCCEEDED(IStream_Write(pStream, pPidl, wLen, NULL)))
343 IStream_Release (pStream);
348 HRESULT WINAPI SHILCreateFromPathA (LPCSTR path, LPITEMIDLIST * ppidl, DWORD * attributes)
350 WCHAR lpszDisplayName[MAX_PATH];
352 HRESULT ret = E_FAIL;
354 TRACE_(shell)("%s %p 0x%08lx\n",path,ppidl,attributes?*attributes:0);
356 if (!MultiByteToWideChar( CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH ))
357 lpszDisplayName[MAX_PATH-1] = 0;
359 if (SUCCEEDED (SHGetDesktopFolder(&sf)))
361 ret = IShellFolder_ParseDisplayName(sf,0, NULL,lpszDisplayName,&pchEaten,ppidl,attributes);
362 IShellFolder_Release(sf);
367 HRESULT WINAPI SHILCreateFromPathW (LPCWSTR path, LPITEMIDLIST * ppidl, DWORD * attributes)
370 HRESULT ret = E_FAIL;
372 TRACE_(shell)("%s %p 0x%08lx\n",debugstr_w(path),ppidl,attributes?*attributes:0);
374 if (SUCCEEDED (SHGetDesktopFolder(&sf)))
376 ret = IShellFolder_ParseDisplayName(sf,0, NULL, (LPWSTR) path, &pchEaten, ppidl, attributes);
377 IShellFolder_Release(sf);
382 /*************************************************************************
383 * SHILCreateFromPath [SHELL32.28]
386 * Wrapper for IShellFolder_ParseDisplayName().
388 HRESULT WINAPI SHILCreateFromPathAW (LPCVOID path, LPITEMIDLIST * ppidl, DWORD * attributes)
390 if ( SHELL_OsIsUnicode())
391 return SHILCreateFromPathW (path, ppidl, attributes);
392 return SHILCreateFromPathA (path, ppidl, attributes);
395 /*************************************************************************
396 * SHCloneSpecialIDList [SHELL32.89]
400 * nFolder [in] CSIDL_xxxxx ??
405 * exported by ordinal
407 LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner,DWORD nFolder,DWORD x3)
408 { LPITEMIDLIST ppidl;
409 WARN_(shell)("(hwnd=%p,csidl=0x%lx,0x%lx):semi-stub.\n",
410 hwndOwner,nFolder,x3);
412 SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl);
417 /*************************************************************************
418 * ILGlobalClone [SHELL32.20]
421 LPITEMIDLIST WINAPI ILGlobalClone(LPCITEMIDLIST pidl)
423 LPITEMIDLIST newpidl;
428 len = ILGetSize(pidl);
429 newpidl = (LPITEMIDLIST)Alloc(len);
431 memcpy(newpidl,pidl,len);
433 TRACE("pidl=%p newpidl=%p\n",pidl, newpidl);
439 /*************************************************************************
440 * ILIsEqual [SHELL32.21]
443 BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
445 char szData1[MAX_PATH];
446 char szData2[MAX_PATH];
448 LPCITEMIDLIST pidltemp1 = pidl1;
449 LPCITEMIDLIST pidltemp2 = pidl2;
451 TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2);
453 /* explorer reads from registry directly (StreamMRU),
454 so we can only check here */
455 if ((!pcheck (pidl1)) || (!pcheck (pidl2))) return FALSE;
460 if ( (!pidl1) || (!pidl2) ) return FALSE;
462 while (pidltemp1->mkid.cb && pidltemp2->mkid.cb)
464 _ILSimpleGetText(pidltemp1, szData1, MAX_PATH);
465 _ILSimpleGetText(pidltemp2, szData2, MAX_PATH);
467 if (strcasecmp ( szData1, szData2 )!=0 )
470 pidltemp1 = ILGetNext(pidltemp1);
471 pidltemp2 = ILGetNext(pidltemp2);
474 if (!pidltemp1->mkid.cb && !pidltemp2->mkid.cb)
481 /*************************************************************************
482 * ILIsParent [SHELL32.23]
484 * parent=a/b child=a/b/c -> true, c is in folder a/b
485 * child=a/b/c/d -> false if bImmediate is true, d is not in folder a/b
486 * child=a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b
488 BOOL WINAPI ILIsParent( LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
490 char szData1[MAX_PATH];
491 char szData2[MAX_PATH];
493 LPCITEMIDLIST pParent = pidlParent;
494 LPCITEMIDLIST pChild = pidlChild;
496 TRACE("%p %p %x\n", pidlParent, pidlChild, bImmediate);
498 while (pParent->mkid.cb && pChild->mkid.cb)
500 _ILSimpleGetText(pParent, szData1, MAX_PATH);
501 _ILSimpleGetText(pChild, szData2, MAX_PATH);
503 if (strcasecmp ( szData1, szData2 )!=0 )
506 pParent = ILGetNext(pParent);
507 pChild = ILGetNext(pChild);
510 if ( pParent->mkid.cb || ! pChild->mkid.cb) /* child shorter or has equal length to parent */
513 if ( ILGetNext(pChild)->mkid.cb && bImmediate) /* not immediate descent */
519 /*************************************************************************
520 * ILFindChild [SHELL32.24]
523 * Compares elements from pidl1 and pidl2.
525 * pidl1 is desktop pidl2
526 * pidl1 shorter pidl2 pointer to first different element of pidl2
527 * if there was at least one equal element
528 * pidl2 shorter pidl1 0
529 * pidl2 equal pidl1 pointer to last 0x00-element of pidl2
531 LPITEMIDLIST WINAPI ILFindChild(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
533 char szData1[MAX_PATH];
534 char szData2[MAX_PATH];
536 LPCITEMIDLIST pidltemp1 = pidl1;
537 LPCITEMIDLIST pidltemp2 = pidl2;
538 LPCITEMIDLIST ret=NULL;
540 TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2);
542 /* explorer reads from registry directly (StreamMRU),
543 so we can only check here */
544 if ((!pcheck (pidl1)) || (!pcheck (pidl2)))
550 if ( _ILIsDesktop(pidl1) )
556 while (pidltemp1->mkid.cb && pidltemp2->mkid.cb)
558 _ILSimpleGetText(pidltemp1, szData1, MAX_PATH);
559 _ILSimpleGetText(pidltemp2, szData2, MAX_PATH);
561 if (strcasecmp(szData1,szData2))
564 pidltemp1 = ILGetNext(pidltemp1);
565 pidltemp2 = ILGetNext(pidltemp2);
569 if (pidltemp1->mkid.cb)
571 ret = NULL; /* elements of pidl1 left*/
574 TRACE_(shell)("--- %p\n", ret);
575 return (LPITEMIDLIST)ret; /* pidl 1 is shorter */
578 /*************************************************************************
579 * ILCombine [SHELL32.25]
582 * Concatenates two complex idlists.
583 * The pidl is the first one, pidlsub the next one
584 * Does not destroy the passed in idlists!
586 LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1,LPCITEMIDLIST pidl2)
589 LPITEMIDLIST pidlNew;
591 TRACE("pidl=%p pidl=%p\n",pidl1,pidl2);
593 if(!pidl1 && !pidl2) return NULL;
600 pidlNew = ILClone(pidl2);
606 pidlNew = ILClone(pidl1);
610 len1 = ILGetSize(pidl1)-2;
611 len2 = ILGetSize(pidl2);
612 pidlNew = SHAlloc(len1+len2);
616 memcpy(pidlNew,pidl1,len1);
617 memcpy(((BYTE *)pidlNew)+len1,pidl2,len2);
620 /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/
623 /*************************************************************************
624 * SHGetRealIDL [SHELL32.98]
628 LPITEMIDLIST WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl, DWORD z)
630 FIXME("sf=%p pidl=%p 0x%04lx\n",lpsf,pidl,z);
636 /*************************************************************************
637 * SHLogILFromFSIL [SHELL32.95]
640 * pild = CSIDL_DESKTOP ret = 0
641 * pild = CSIDL_DRIVES ret = 0
643 LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl)
645 FIXME("(pidl=%p)\n",pidl);
652 /*************************************************************************
653 * ILGetSize [SHELL32.152]
654 * gets the byte size of an idlist including zero terminator (pidl)
663 * exported by ordinal
665 DWORD WINAPI ILGetSize(LPCITEMIDLIST pidl)
667 LPCSHITEMID si = &(pidl->mkid);
673 si = (LPSHITEMID)(((LPBYTE)si)+si->cb);
677 TRACE("pidl=%p size=%lu\n",pidl, len);
681 /*************************************************************************
682 * ILGetNext [SHELL32.153]
683 * gets the next simple pidl of a complex pidl
685 * observed return values:
688 * simple pidl -> pointer to 0x0000 element
691 LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
702 pidl = (LPITEMIDLIST) (((LPBYTE)pidl)+len);
703 TRACE("-- %p\n", pidl);
704 return (LPITEMIDLIST)pidl;
709 /*************************************************************************
710 * ILAppend [SHELL32.154]
713 * Adds the single item to the idlist indicated by pidl.
714 * if bEnd is 0, adds the item to the front of the list,
715 * otherwise adds the item to the end. (???)
716 * Destroys the passed in idlist! (???)
718 LPITEMIDLIST WINAPI ILAppend(LPITEMIDLIST pidl,LPCITEMIDLIST item,BOOL bEnd)
722 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd);
727 if (_ILIsDesktop(pidl))
729 idlRet = ILClone(item);
737 idlRet=ILCombine(pidl,item);
741 idlRet=ILCombine(item,pidl);
747 /*************************************************************************
748 * ILFree [SHELL32.155]
751 * free_check_ptr - frees memory (if not NULL)
752 * allocated by SHMalloc allocator
753 * exported by ordinal
755 DWORD WINAPI ILFree(LPITEMIDLIST pidl)
757 TRACE("(pidl=0x%08lx)\n",(DWORD)pidl);
759 if(!pidl) return FALSE;
763 /*************************************************************************
764 * ILGlobalFree [SHELL32.156]
767 void WINAPI ILGlobalFree( LPITEMIDLIST pidl)
774 /*************************************************************************
775 * ILCreateFromPath [SHELL32.157]
778 LPITEMIDLIST WINAPI ILCreateFromPathA (LPCSTR path)
780 LPITEMIDLIST pidlnew;
781 DWORD attributes = 0;
783 TRACE_(shell)("%s\n",path);
785 if (SUCCEEDED (SHILCreateFromPathA (path, &pidlnew, &attributes)))
789 LPITEMIDLIST WINAPI ILCreateFromPathW (LPCWSTR path)
791 LPITEMIDLIST pidlnew;
792 DWORD attributes = 0;
794 TRACE_(shell)("%s\n",debugstr_w(path));
796 if (SUCCEEDED (SHILCreateFromPathW (path, &pidlnew, &attributes)))
800 LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path)
802 if ( SHELL_OsIsUnicode())
803 return ILCreateFromPathW (path);
804 return ILCreateFromPathA (path);
806 /*************************************************************************
807 * SHSimpleIDListFromPath [SHELL32.162]
809 LPITEMIDLIST WINAPI SHSimpleIDListFromPathA (LPCSTR lpszPath)
811 LPITEMIDLIST pidl=NULL;
813 WIN32_FIND_DATAA stffile;
815 TRACE("path=%s\n", lpszPath);
817 if (!lpszPath) return NULL;
819 hFile = FindFirstFileA(lpszPath, &stffile);
821 if ( hFile != INVALID_HANDLE_VALUE )
823 if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
825 pidl = _ILCreateFolder (&stffile);
829 pidl = _ILCreateValue (&stffile);
835 LPITEMIDLIST WINAPI SHSimpleIDListFromPathW (LPCWSTR lpszPath)
837 char lpszTemp[MAX_PATH];
838 TRACE("path=%s\n",debugstr_w(lpszPath));
840 if (!WideCharToMultiByte( CP_ACP, 0, lpszPath, -1, lpszTemp, sizeof(lpszTemp), NULL, NULL ))
841 lpszTemp[sizeof(lpszTemp)-1] = 0;
843 return SHSimpleIDListFromPathA (lpszTemp);
846 LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW (LPCVOID lpszPath)
848 if ( SHELL_OsIsUnicode())
849 return SHSimpleIDListFromPathW (lpszPath);
850 return SHSimpleIDListFromPathA (lpszPath);
853 /*************************************************************************
854 * SHGetSpecialFolderLocation [SHELL32.@]
856 * gets the folder locations from the registry and creates a pidl
857 * creates missing reg keys and directories
861 * nFolder [I] CSIDL_xxxxx
862 * ppidl [O] PIDL of a special folder
865 HRESULT WINAPI SHGetSpecialFolderLocation(
868 LPITEMIDLIST * ppidl)
870 CHAR szPath[MAX_PATH];
871 HRESULT hr = E_INVALIDARG;
873 TRACE_(shell)("(%p,0x%x,%p)\n", hwndOwner,nFolder,ppidl);
881 *ppidl = _ILCreateDesktop();
885 *ppidl = _ILCreateMyComputer();
889 *ppidl = _ILCreateNetwork ();
893 *ppidl = _ILCreateControl ();
897 *ppidl = _ILCreatePrinter ();
900 case CSIDL_BITBUCKET:
901 *ppidl = _ILCreateBitBucket ();
905 if (SHGetSpecialFolderPathA(hwndOwner, szPath, nFolder, TRUE))
908 TRACE_(shell)("Value=%s\n",szPath);
909 hr = SHILCreateFromPathA(szPath, ppidl, &attributes);
912 if(*ppidl) hr = NOERROR;
915 TRACE_(shell)("-- (new pidl %p)\n",*ppidl);
919 /*************************************************************************
920 * SHGetFolderLocation [SHELL32.@]
923 * the pidl can be a simple one. since we cant get the path out of the pidl
924 * we have to take all data from the pidl
926 HRESULT WINAPI SHGetFolderLocation(
933 FIXME("%p 0x%08x %p 0x%08lx %p\n",
934 hwnd, csidl, hToken, dwFlags, ppidl);
935 return SHGetSpecialFolderLocation(hwnd, csidl, ppidl);
938 /*************************************************************************
939 * SHGetDataFromIDListA [SHELL32.247]
942 * the pidl can be a simple one. since we cant get the path out of the pidl
943 * we have to take all data from the pidl
945 HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
947 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
950 if (!psf || !dest ) return E_INVALIDARG;
954 case SHGDFIL_FINDDATA:
956 WIN32_FIND_DATAA * pfd = dest;
958 if ( len < sizeof (WIN32_FIND_DATAA)) return E_INVALIDARG;
960 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
961 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
962 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
963 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
964 lstrcpynA(pfd->cFileName,_ILGetTextPointer(pidl), MAX_PATH);
965 lstrcpynA(pfd->cAlternateFileName,_ILGetSTextPointer(pidl), 14);
969 case SHGDFIL_NETRESOURCE:
970 case SHGDFIL_DESCRIPTIONID:
971 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
975 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
980 /*************************************************************************
981 * SHGetDataFromIDListW [SHELL32.248]
984 HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
986 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
990 if (! psf || !dest ) return E_INVALIDARG;
994 case SHGDFIL_FINDDATA:
996 WIN32_FIND_DATAW * pfd = dest;
998 if ( len < sizeof (WIN32_FIND_DATAW)) return E_INVALIDARG;
1000 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
1001 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1002 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1003 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1004 if (!MultiByteToWideChar( CP_ACP, 0, _ILGetTextPointer(pidl), -1,
1005 pfd->cFileName, MAX_PATH ))
1006 pfd->cFileName[MAX_PATH-1] = 0;
1007 if (!MultiByteToWideChar( CP_ACP, 0, _ILGetSTextPointer(pidl), -1,
1008 pfd->cAlternateFileName, 14 ))
1009 pfd->cFileName[13] = 0;
1012 case SHGDFIL_NETRESOURCE:
1013 case SHGDFIL_DESCRIPTIONID:
1014 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1018 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1021 return E_INVALIDARG;
1024 /*************************************************************************
1025 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
1029 * pszPath [OUT] path
1032 * path from a passed PIDL.
1035 * NULL returns FALSE
1036 * desktop pidl gives path to desktopdirectory back
1037 * special pidls returning FALSE
1039 BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
1043 LPSHELLFOLDER shellfolder;
1045 TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
1048 if (!pidl) return FALSE;
1050 hr = SHGetDesktopFolder(&shellfolder);
1051 if (SUCCEEDED (hr)) {
1052 hr = IShellFolder_GetDisplayNameOf(shellfolder,pidl,SHGDN_FORPARSING,&str);
1054 StrRetToStrNA (pszPath, MAX_PATH, &str, pidl);
1056 IShellFolder_Release(shellfolder);
1059 TRACE_(shell)("-- %s, 0x%08lx\n",pszPath, hr);
1060 return SUCCEEDED(hr);
1062 /*************************************************************************
1063 * SHGetPathFromIDListW [SHELL32.@]
1065 BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
1069 LPSHELLFOLDER shellfolder;
1071 TRACE_(shell)("(pidl=%p,%p)\n", pidl, debugstr_w(pszPath));
1074 if (!pidl) return FALSE;
1076 hr = SHGetDesktopFolder(&shellfolder);
1077 if (SUCCEEDED(hr)) {
1078 hr = IShellFolder_GetDisplayNameOf(shellfolder, pidl, SHGDN_FORPARSING, &str);
1079 if (SUCCEEDED(hr)) {
1080 StrRetToStrNW(pszPath, MAX_PATH, &str, pidl);
1082 IShellFolder_Release(shellfolder);
1085 TRACE_(shell)("-- %s, 0x%08lx\n",debugstr_w(pszPath), hr);
1086 return SUCCEEDED(hr);
1089 /*************************************************************************
1090 * SHBindToParent [shell version 5.0]
1092 HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
1095 LPITEMIDLIST pidlChild, pidlParent;
1098 TRACE_(shell)("pidl=%p\n", pidl);
1102 if (ppidlLast) *ppidlLast = NULL;
1104 if (_ILIsPidlSimple(pidl))
1106 /* we are on desktop level */
1108 *ppidlLast = ILClone(pidl);
1109 hr = SHGetDesktopFolder((IShellFolder**)ppv);
1113 pidlChild = ILClone(ILFindLastID(pidl));
1114 pidlParent = ILClone(pidl);
1115 ILRemoveLastID(pidlParent);
1117 hr = SHGetDesktopFolder(&psf);
1120 hr = IShellFolder_BindToObject(psf, pidlParent, NULL, riid, ppv);
1122 if (SUCCEEDED(hr) && ppidlLast)
1123 *ppidlLast = pidlChild;
1127 SHFree (pidlParent);
1128 if (psf) IShellFolder_Release(psf);
1132 TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08lx\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr);
1136 /*************************************************************************
1137 * SHGetPathFromIDList [SHELL32.@][NT 4.0: SHELL32.219]
1139 BOOL WINAPI SHGetPathFromIDListAW(LPCITEMIDLIST pidl,LPVOID pszPath)
1141 TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
1143 if (SHELL_OsIsUnicode())
1144 return SHGetPathFromIDListW(pidl,pszPath);
1145 return SHGetPathFromIDListA(pidl,pszPath);
1148 /**************************************************************************
1150 * internal functions
1152 * ### 1. section creating pidls ###
1154 *************************************************************************
1155 * _ILCreateDesktop()
1156 * _ILCreateIExplore()
1157 * _ILCreateMyComputer()
1162 LPITEMIDLIST _ILCreateDesktop()
1164 return _ILCreate(PT_DESKTOP, NULL, 0);
1167 LPITEMIDLIST _ILCreateMyComputer()
1169 return _ILCreate(PT_MYCOMP, &CLSID_MyComputer, sizeof(GUID));
1172 LPITEMIDLIST _ILCreateIExplore()
1174 return _ILCreate(PT_MYCOMP, &CLSID_Internet, sizeof(GUID));
1177 LPITEMIDLIST _ILCreateControl()
1179 return _ILCreate(PT_SPECIAL, &CLSID_ControlPanel, sizeof(GUID));
1182 LPITEMIDLIST _ILCreatePrinter()
1184 return _ILCreate(PT_SPECIAL, &CLSID_Printers, sizeof(GUID));
1187 LPITEMIDLIST _ILCreateNetwork()
1189 return _ILCreate(PT_MYCOMP, &CLSID_NetworkPlaces, sizeof(GUID));
1192 LPITEMIDLIST _ILCreateBitBucket()
1194 return _ILCreate(PT_MYCOMP, &CLSID_RecycleBin, sizeof(GUID));
1197 LPITEMIDLIST _ILCreateDrive( LPCSTR lpszNew)
1199 lstrcpynA (sTemp,lpszNew,4);
1202 TRACE("(%s)\n",sTemp);
1203 return _ILCreate(PT_DRIVE,(LPVOID)&sTemp[0],4);
1206 LPITEMIDLIST _ILCreateFolder( WIN32_FIND_DATAA * stffile )
1208 char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */
1209 char * pbuff = buff;
1213 TRACE("(%s, %s)\n",stffile->cAlternateFileName, stffile->cFileName);
1215 /* prepare buffer with both names */
1216 len = strlen (stffile->cFileName) + 1;
1217 memcpy (pbuff, stffile->cFileName, len);
1220 if (stffile->cAlternateFileName)
1222 len1 = strlen (stffile->cAlternateFileName)+1;
1223 memcpy (pbuff, stffile->cAlternateFileName, len1);
1231 pidl = _ILCreate(PT_FOLDER, (LPVOID)buff, len + len1);
1233 /* set attributes */
1237 pData = _ILGetDataPointer(pidl);
1238 FileTimeToDosDateTime(&(stffile->ftLastWriteTime),&pData->u.folder.uFileDate,&pData->u.folder.uFileTime);
1239 pData->u.folder.dwFileSize = stffile->nFileSizeLow;
1240 pData->u.folder.uFileAttribs = stffile->dwFileAttributes;
1246 LPITEMIDLIST _ILCreateValue(WIN32_FIND_DATAA * stffile)
1248 char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */
1249 char * pbuff = buff;
1253 TRACE("(%s, %s)\n",stffile->cAlternateFileName, stffile->cFileName);
1255 /* prepare buffer with both names */
1256 len = strlen (stffile->cFileName) + 1;
1257 memcpy (pbuff, stffile->cFileName, len);
1260 if (stffile->cAlternateFileName)
1262 len1 = strlen (stffile->cAlternateFileName)+1;
1263 memcpy (pbuff, stffile->cAlternateFileName, len1);
1271 pidl = _ILCreate(PT_VALUE, (LPVOID)buff, len + len1);
1273 /* set attributes */
1277 pData = _ILGetDataPointer(pidl);
1278 FileTimeToDosDateTime(&(stffile->ftLastWriteTime),&pData->u.folder.uFileDate,&pData->u.folder.uFileTime);
1279 pData->u.folder.dwFileSize = stffile->nFileSizeLow;
1280 pData->u.folder.uFileAttribs=stffile->dwFileAttributes;
1286 LPITEMIDLIST _ILCreateFromPathA(LPCSTR szPath)
1289 WIN32_FIND_DATAA stffile;
1290 LPITEMIDLIST pidl = NULL;
1292 hFile = FindFirstFileA(szPath, &stffile);
1293 if (hFile != INVALID_HANDLE_VALUE)
1295 if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1296 pidl = _ILCreateFolder(&stffile);
1298 pidl = _ILCreateValue(&stffile);
1304 LPITEMIDLIST _ILCreateSpecial(LPCSTR szGUID)
1308 if (!SUCCEEDED(SHCLSIDFromStringA(szGUID, &iid)))
1310 ERR("%s is not a GUID\n", szGUID);
1313 return _ILCreate(PT_MYCOMP, &iid, sizeof(IID));
1316 /**************************************************************************
1318 * Creates a new PIDL
1319 * type = PT_DESKTOP | PT_DRIVE | PT_FOLDER | PT_VALUE
1321 * uInSize = size of data (raw)
1324 LPITEMIDLIST _ILCreate(PIDLTYPE type, LPCVOID pIn, UINT uInSize)
1326 LPITEMIDLIST pidlOut = NULL, pidlTemp = NULL;
1331 TRACE("(0x%02x %p %i)\n",type,pIn,uInSize);
1340 uSize = 2 + 2 + sizeof(GUID);
1347 uSize = 2 + 12 + uInSize;
1350 FIXME("can't create type: 0x%08x\n",type);
1354 if(!(pidlOut = SHAlloc(uSize + 2))) return NULL;
1355 ZeroMemory(pidlOut, uSize + 2);
1356 pidlOut->mkid.cb = uSize;
1361 TRACE("- create Desktop\n");
1366 pData = _ILGetDataPointer(pidlOut);
1368 memcpy(&(pData->u.mycomp.guid), pIn, uInSize);
1369 TRACE("-- create GUID-pidl %s\n", debugstr_guid(&(pData->u.mycomp.guid)));
1373 pData = _ILGetDataPointer(pidlOut);
1375 pszDest = _ILGetTextPointer(pidlOut);
1376 memcpy(pszDest, pIn, uInSize);
1377 TRACE("-- create Drive: %s\n",debugstr_a(pszDest));
1382 pData = _ILGetDataPointer(pidlOut);
1384 pszDest = _ILGetTextPointer(pidlOut);
1385 memcpy(pszDest, pIn, uInSize);
1386 TRACE("-- create Value: %s\n",debugstr_a(pszDest));
1390 pidlTemp = ILGetNext(pidlOut);
1392 pidlTemp->mkid.cb = 0x00;
1394 TRACE("-- (pidl=%p, size=%u)\n", pidlOut, uSize);
1398 /**************************************************************************
1401 * Gets the text for the drive eg. 'c:\'
1406 DWORD _ILGetDrive(LPCITEMIDLIST pidl,LPSTR pOut, UINT uSize)
1407 { TRACE("(%p,%p,%u)\n",pidl,pOut,uSize);
1409 if(_ILIsMyComputer(pidl))
1410 pidl = ILGetNext(pidl);
1412 if (pidl && _ILIsDrive(pidl))
1413 return _ILSimpleGetText(pidl, pOut, uSize);
1418 /**************************************************************************
1420 * ### 2. section testing pidls ###
1422 **************************************************************************
1425 * _ILIsSpecialFolder()
1431 BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
1432 { TRACE("(%p)\n",pidl);
1433 return pidl && pidl->mkid.cb ? 0 : 1;
1436 BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
1438 REFIID iid = _ILGetGUIDPointer(pidl);
1440 TRACE("(%p)\n",pidl);
1443 return IsEqualIID(iid, &CLSID_MyComputer);
1447 BOOL _ILIsSpecialFolder (LPCITEMIDLIST pidl)
1449 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
1450 TRACE("(%p)\n",pidl);
1451 return (pidl && ( (lpPData && (PT_MYCOMP== lpPData->type || PT_SPECIAL== lpPData->type)) ||
1452 (pidl && pidl->mkid.cb == 0x00)
1456 BOOL _ILIsDrive(LPCITEMIDLIST pidl)
1457 { LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
1458 TRACE("(%p)\n",pidl);
1459 return (pidl && lpPData && (PT_DRIVE == lpPData->type ||
1460 PT_DRIVE1 == lpPData->type ||
1461 PT_DRIVE2 == lpPData->type ||
1462 PT_DRIVE3 == lpPData->type));
1465 BOOL _ILIsFolder(LPCITEMIDLIST pidl)
1466 { LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
1467 TRACE("(%p)\n",pidl);
1468 return (pidl && lpPData && (PT_FOLDER == lpPData->type || PT_FOLDER1 == lpPData->type));
1471 BOOL _ILIsValue(LPCITEMIDLIST pidl)
1472 { LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
1473 TRACE("(%p)\n",pidl);
1474 return (pidl && lpPData && PT_VALUE == lpPData->type);
1477 /**************************************************************************
1480 BOOL _ILIsPidlSimple ( LPCITEMIDLIST pidl)
1484 if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */
1486 WORD len = pidl->mkid.cb;
1487 LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((LPBYTE)pidl) + len );
1488 if (pidlnext->mkid.cb)
1492 TRACE("%s\n", ret ? "Yes" : "No");
1496 /**************************************************************************
1498 * ### 3. section getting values from pidls ###
1501 /**************************************************************************
1504 * gets the text for the first item in the pidl (eg. simple pidl)
1506 * returns the length of the string
1508 DWORD _ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
1513 char szTemp[MAX_PATH];
1515 TRACE("(%p %p %x)\n",pidl,szOut,uOutSize);
1517 if (!pidl) return 0;
1522 if (_ILIsDesktop(pidl))
1525 if (HCR_GetClassNameA(&CLSID_ShellDesktop, szTemp, MAX_PATH))
1528 lstrcpynA(szOut, szTemp, uOutSize);
1530 dwReturn = strlen (szTemp);
1533 else if (( szSrc = _ILGetTextPointer(pidl) ))
1537 lstrcpynA(szOut, szSrc, uOutSize);
1539 dwReturn = strlen(szSrc);
1541 else if (( riid = _ILGetGUIDPointer(pidl) ))
1543 /* special folder */
1544 if ( HCR_GetClassNameA(riid, szTemp, MAX_PATH) )
1547 lstrcpynA(szOut, szTemp, uOutSize);
1549 dwReturn = strlen (szTemp);
1554 ERR("-- no text\n");
1557 TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_a(szOut),dwReturn);
1561 /**************************************************************************
1564 * gets the text for the first item in the pidl (eg. simple pidl)
1566 * returns the length of the string
1568 DWORD _ILSimpleGetTextW (LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
1571 char szTemp[MAX_PATH];
1573 TRACE("(%p %p %x)\n",pidl,szOut,uOutSize);
1575 dwReturn = _ILSimpleGetText(pidl, szTemp, uOutSize);
1577 if (!MultiByteToWideChar(CP_ACP, 0, szTemp, -1, szOut, MAX_PATH))
1580 TRACE("-- (%p=%s 0x%08lx)\n",szOut,debugstr_w(szOut),dwReturn);
1584 /**************************************************************************
1586 * ### 4. getting pointers to parts of pidls ###
1588 **************************************************************************
1589 * _ILGetDataPointer()
1591 LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
1593 if(pidl && pidl->mkid.cb != 0x00)
1594 return (LPPIDLDATA) &(pidl->mkid.abID);
1598 /**************************************************************************
1599 * _ILGetTextPointer()
1600 * gets a pointer to the long filename string stored in the pidl
1602 LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl)
1603 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1605 LPPIDLDATA pdata = _ILGetDataPointer(pidl);
1609 switch (pdata->type)
1619 return (LPSTR)&(pdata->u.drive.szDriveName);
1626 return (LPSTR)&(pdata->u.file.szNames);
1631 case PT_NETPROVIDER:
1633 return (LPSTR)&(pdata->u.network.szNames);
1639 /**************************************************************************
1640 * _ILGetSTextPointer()
1641 * gets a pointer to the short filename string stored in the pidl
1643 LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl)
1644 {/* TRACE(pidl,"(pidl%p)\n", pidl);*/
1646 LPPIDLDATA pdata =_ILGetDataPointer(pidl);
1650 switch (pdata->type)
1656 return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1);
1659 return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1);
1665 /**************************************************************************
1666 * _ILGetGUIDPointer()
1668 * returns reference to guid stored in some pidls
1670 REFIID _ILGetGUIDPointer(LPCITEMIDLIST pidl)
1672 LPPIDLDATA pdata =_ILGetDataPointer(pidl);
1674 TRACE("%p\n", pidl);
1678 TRACE("pdata->type 0x%04x\n", pdata->type);
1679 switch (pdata->type)
1683 return (REFIID) &(pdata->u.mycomp.guid);
1686 TRACE("Unknown pidl type 0x%04x\n", pdata->type);
1693 /*************************************************************************
1694 * _ILGetFileDateTime
1696 * Given the ItemIdList, get the FileTime
1699 * pidl [I] The ItemIDList
1700 * pFt [I] the resulted FILETIME of the file
1703 * True if Successful
1708 BOOL _ILGetFileDateTime(LPCITEMIDLIST pidl, FILETIME *pFt)
1710 LPPIDLDATA pdata = _ILGetDataPointer(pidl);
1712 if(! pdata) return FALSE;
1714 switch (pdata->type)
1717 DosDateTimeToFileTime(pdata->u.folder.uFileDate, pdata->u.folder.uFileTime, pFt);
1720 DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt);
1728 BOOL _ILGetFileDate (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
1734 if (_ILGetFileDateTime( pidl, &ft )) {
1735 FileTimeToLocalFileTime(&ft, &lft);
1736 FileTimeToSystemTime (&lft, &time);
1737 ret = GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&time, NULL, pOut, uOutSize);
1746 /*************************************************************************
1749 * Given the ItemIdList, get the FileSize
1752 * pidl [I] The ItemIDList
1753 * pOut [I] The buffer to save the result
1754 * uOutsize [I] The size of the buffer
1760 * pOut can be null when no string is needed
1763 DWORD _ILGetFileSize (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
1765 LPPIDLDATA pdata = _ILGetDataPointer(pidl);
1768 if(! pdata) return 0;
1770 switch (pdata->type)
1773 dwSize = pdata->u.file.dwFileSize;
1774 if (pOut) StrFormatByteSizeA(dwSize, pOut, uOutSize);
1777 if (pOut) *pOut = 0x00;
1781 BOOL _ILGetExtension (LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
1783 char szTemp[MAX_PATH];
1784 const char * pPoint;
1785 LPCITEMIDLIST pidlTemp=pidl;
1787 TRACE("pidl=%p\n",pidl);
1789 if (!pidl) return FALSE;
1791 pidlTemp = ILFindLastID(pidl);
1793 if (!_ILIsValue(pidlTemp)) return FALSE;
1794 if (!_ILSimpleGetText(pidlTemp, szTemp, MAX_PATH)) return FALSE;
1796 pPoint = PathFindExtensionA(szTemp);
1798 if (! *pPoint) return FALSE;
1801 lstrcpynA(pOut, pPoint, uOutSize);
1807 /*************************************************************************
1810 * Given the ItemIdList, get the file type description
1813 * pidl [I] The ItemIDList (simple)
1814 * pOut [I] The buffer to save the result
1815 * uOutsize [I] The size of the buffer
1821 * This function copies as much as possible into the buffer.
1823 void _ILGetFileType(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
1825 if(_ILIsValue(pidl))
1832 if (_ILGetExtension (pidl, sTemp, 64))
1834 if (!( HCR_MapTypeToValueA(sTemp, sTemp, 64, TRUE)
1835 && HCR_MapTypeToValueA(sTemp, pOut, uOutSize, FALSE )))
1837 lstrcpynA (pOut, sTemp, uOutSize - 6);
1838 strcat (pOut, "-file");
1844 lstrcpynA(pOut, "Folder", uOutSize);
1848 /*************************************************************************
1849 * _ILGetFileAttributes
1851 * Given the ItemIdList, get the Attrib string format
1854 * pidl [I] The ItemIDList
1855 * pOut [I] The buffer to save the result
1856 * uOutsize [I] The size of the Buffer
1862 * return value 0 in case of error is a valid return value
1865 DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPSTR pOut, UINT uOutSize)
1867 LPPIDLDATA pData = _ILGetDataPointer(pidl);
1871 if(! pData) return 0;
1876 wAttrib = pData->u.folder.uFileAttribs;
1879 wAttrib = pData->u.file.uFileAttribs;
1886 if(wAttrib & FILE_ATTRIBUTE_READONLY)
1890 if(wAttrib & FILE_ATTRIBUTE_HIDDEN)
1894 if(wAttrib & FILE_ATTRIBUTE_SYSTEM)
1898 if(wAttrib & FILE_ATTRIBUTE_ARCHIVE)
1902 if(wAttrib & FILE_ATTRIBUTE_COMPRESSED)
1911 /*************************************************************************
1914 * free a aPidl struct
1916 void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl)
1922 for (i = 0; i < cidl; i++) SHFree(apidl[i]);
1927 /*************************************************************************
1930 * copies an aPidl struct
1932 LPITEMIDLIST* _ILCopyaPidl(LPCITEMIDLIST * apidlsrc, UINT cidl)
1935 LPITEMIDLIST * apidldest = (LPITEMIDLIST*)SHAlloc(cidl * sizeof(LPITEMIDLIST));
1936 if(!apidlsrc) return NULL;
1938 for (i = 0; i < cidl; i++)
1939 apidldest[i] = ILClone(apidlsrc[i]);
1944 /*************************************************************************
1945 * _ILCopyCidaToaPidl
1947 * creates aPidl from CIDA
1949 LPITEMIDLIST* _ILCopyCidaToaPidl(LPITEMIDLIST* pidl, LPIDA cida)
1952 LPITEMIDLIST * dst = (LPITEMIDLIST*)SHAlloc(cida->cidl * sizeof(LPITEMIDLIST));
1954 if(!dst) return NULL;
1957 *pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[0]]));
1959 for (i = 0; i < cida->cidl; i++)
1960 dst[i] = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[i + 1]]));