ReactOS 0.4.16-dev-973-g9a0ff8b
pidl.c
Go to the documentation of this file.
1/*
2 * pidl Handling
3 *
4 * Copyright 1998 Juergen Schmied
5 *
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.
10 *
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.
15 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 * NOTES
21 * a pidl == NULL means desktop and is legal
22 *
23 */
24
25#include <wine/config.h>
26
27#define WIN32_NO_STATUS
28#define _INC_WINDOWS
29#define COBJMACROS
30#define NONAMELESSUNION
31#define NONAMELESSSTRUCT
32
33#include <windef.h>
34#include <winbase.h>
35#include <strsafe.h>
36#include <shlobj.h>
37#include <undocshell.h>
38#include <shlwapi.h>
39#include <shlguid_undoc.h>
40#include <wine/debug.h>
41#include <wine/unicode.h>
42
43#include "pidl.h"
44#include "shell32_main.h"
45#include "shresdef.h"
46
49
50/* from comctl32.dll */
52extern BOOL WINAPI Free(LPVOID);
53
56
58
61 _In_ IBindCtx *pBindCtx,
62 _In_ LPOLESTR pszKey,
63 _In_opt_ IUnknown *punk,
64 _Out_ LPBC *ppbc);
65
66/*************************************************************************
67 * ILGetDisplayNameExA
68 *
69 * Retrieves the display name of an ItemIDList
70 *
71 * PARAMS
72 * psf [I] Shell Folder to start with, if NULL the desktop is used
73 * pidl [I] ItemIDList relative to the psf to get the display name for
74 * path [O] Filled in with the display name, assumed to be at least MAX_PATH long
75 * type [I] Type of display name to retrieve
76 * 0 = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR uses always the desktop as root
77 * 1 = SHGDN_NORMAL relative to the root folder
78 * 2 = SHGDN_INFOLDER relative to the root folder, only the last name
79 *
80 * RETURNS
81 * True if the display name could be retrieved successfully, False otherwise
82 */
83static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
84{
85 BOOL ret = FALSE;
86 WCHAR wPath[MAX_PATH];
87
88 TRACE("%p %p %p %d\n", psf, pidl, path, type);
89
90 if (!pidl || !path)
91 return FALSE;
92
93 ret = ILGetDisplayNameExW(psf, pidl, wPath, type);
95 TRACE("%p %p %s\n", psf, pidl, debugstr_a(path));
96
97 return ret;
98}
99
101{
102 LPSHELLFOLDER psfParent, lsf = psf;
104 LPCITEMIDLIST pidllast;
105 STRRET strret;
106 DWORD flag;
107
108 TRACE("%p %p %p %x\n", psf, pidl, path, type);
109
110 if (!pidl || !path)
111 return FALSE;
112
113 if (!lsf)
114 {
115 ret = SHGetDesktopFolder(&lsf);
116 if (FAILED(ret))
117 return FALSE;
118 }
119
120 switch (type)
121 {
122 case ILGDN_FORPARSING:
123 flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR;
124 break;
125 case ILGDN_NORMAL:
126 flag = SHGDN_NORMAL;
127 break;
128 case ILGDN_INFOLDER:
129 flag = SHGDN_INFOLDER;
130 break;
131 default:
132 FIXME("Unknown type parameter = %x\n", type);
133 flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR;
134 break;
135 }
136
137 if (!*(const WORD*)pidl || type == ILGDN_FORPARSING)
138 {
139 ret = IShellFolder_GetDisplayNameOf(lsf, pidl, flag, &strret);
140 if (SUCCEEDED(ret))
141 {
142 if(!StrRetToStrNW(path, MAX_PATH, &strret, pidl))
143 ret = E_FAIL;
144 }
145 }
146 else
147 {
148 ret = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidllast);
149 if (SUCCEEDED(ret))
150 {
151 ret = IShellFolder_GetDisplayNameOf(psfParent, pidllast, flag, &strret);
152 if (SUCCEEDED(ret))
153 {
154 if(!StrRetToStrNW(path, MAX_PATH, &strret, pidllast))
155 ret = E_FAIL;
156 }
157 IShellFolder_Release(psfParent);
158 }
159 }
160
161 TRACE("%p %p %s\n", psf, pidl, debugstr_w(path));
162
163 if (!psf)
164 IShellFolder_Release(lsf);
165 return SUCCEEDED(ret);
166}
167
168/*************************************************************************
169 * ILGetDisplayNameEx [SHELL32.186]
170 */
172{
173 TRACE_(shell)("%p %p %p %d\n", psf, pidl, path, type);
174
175 if (SHELL_OsIsUnicode())
176 return ILGetDisplayNameExW(psf, pidl, path, type);
177 return ILGetDisplayNameExA(psf, pidl, path, type);
178}
179
180/*************************************************************************
181 * ILGetDisplayName [SHELL32.15]
182 */
184{
185 TRACE_(shell)("%p %p\n", pidl, path);
186
187 if (SHELL_OsIsUnicode())
190}
191
192/*************************************************************************
193 * ILFindLastID [SHELL32.16]
194 *
195 * NOTES
196 * observed: pidl=Desktop return=pidl
197 */
199{
200 LPCITEMIDLIST pidlLast = pidl;
201
202 TRACE("(pidl=%p)\n",pidl);
203
204 if (!pidl)
205 return NULL;
206
207 while (pidl->mkid.cb)
208 {
209 pidlLast = pidl;
210 pidl = ILGetNext(pidl);
211 }
212 return (LPITEMIDLIST)pidlLast;
213}
214
215/*************************************************************************
216 * ILRemoveLastID [SHELL32.17]
217 *
218 * NOTES
219 * when pidl=Desktop return=FALSE
220 */
222{
223 TRACE_(shell)("pidl=%p\n",pidl);
224
225 if (_ILIsEmpty(pidl))
226 return FALSE;
227 ILFindLastID(pidl)->mkid.cb = 0;
228 return TRUE;
229}
230
231/*************************************************************************
232 * ILClone [SHELL32.18]
233 *
234 * NOTES
235 * duplicate an idlist
236 */
238{
239 DWORD len;
240 LPITEMIDLIST newpidl;
241
242 if (!pidl)
243 return NULL;
244
245 len = ILGetSize(pidl);
246 newpidl = SHAlloc(len);
247 if (newpidl)
248 memcpy(newpidl,pidl,len);
249
250 TRACE("pidl=%p newpidl=%p\n",pidl, newpidl);
251 pdump(pidl);
252
253 return newpidl;
254}
255
256/*************************************************************************
257 * ILCloneFirst [SHELL32.19]
258 *
259 * NOTES
260 * duplicates the first idlist of a complex pidl
261 */
263{
264 DWORD len;
265 LPITEMIDLIST pidlNew = NULL;
266
267 TRACE("pidl=%p\n", pidl);
268 pdump(pidl);
269
270 if (pidl)
271 {
272 len = pidl->mkid.cb;
273 pidlNew = SHAlloc(len+2);
274 if (pidlNew)
275 {
276 memcpy(pidlNew,pidl,len+2); /* 2 -> mind a desktop pidl */
277
278 if (len)
279 ILGetNext(pidlNew)->mkid.cb = 0x00;
280 }
281 }
282 TRACE("-- newpidl=%p\n",pidlNew);
283
284 return pidlNew;
285}
286
287/*************************************************************************
288 * ILLoadFromStream (SHELL32.26)
289 *
290 * NOTES
291 * the first two bytes are the len, the pidl is following then
292 */
294{
295 WORD wLen = 0;
296 DWORD dwBytesRead;
298
299
300 TRACE_(shell)("%p %p\n", pStream , ppPidl);
301
302 SHFree(*ppPidl);
303 *ppPidl = NULL;
304
305 IStream_AddRef (pStream);
306
307 if (SUCCEEDED(IStream_Read(pStream, &wLen, 2, &dwBytesRead)))
308 {
309 TRACE("PIDL length is %d\n", wLen);
310 if (wLen != 0)
311 {
312 *ppPidl = SHAlloc (wLen);
313 if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead)))
314 {
315 TRACE("Stream read OK\n");
316 ret = S_OK;
317 }
318 else
319 {
320 WARN("reading pidl failed\n");
321 SHFree(*ppPidl);
322 *ppPidl = NULL;
323 }
324 }
325 else
326 {
327 *ppPidl = NULL;
328 ret = S_OK;
329 }
330 }
331
332 /* we are not yet fully compatible */
333 if (*ppPidl && !pcheck(*ppPidl))
334 {
335 WARN("Check failed\n");
336#ifndef __REACTOS__ /* We don't know all pidl formats, must allow loading unknown */
337 SHFree(*ppPidl);
338 *ppPidl = NULL;
339#endif
340 }
341
342 IStream_Release (pStream);
343 TRACE("done\n");
344 return ret;
345}
346
347/*************************************************************************
348 * ILSaveToStream (SHELL32.27)
349 *
350 * NOTES
351 * the first two bytes are the len, the pidl is following then
352 */
354{
355 WORD wLen = 0;
357
358 TRACE_(shell)("%p %p\n", pStream, pPidl);
359
360 IStream_AddRef (pStream);
361
362 wLen = ILGetSize(pPidl);
363
364 if (SUCCEEDED(IStream_Write(pStream, &wLen, 2, NULL)))
365 {
366 if (SUCCEEDED(IStream_Write(pStream, pPidl, wLen, NULL)))
367 ret = S_OK;
368 }
369 IStream_Release (pStream);
370
371 return ret;
372}
373
374/*************************************************************************
375 * SHILCreateFromPath [SHELL32.28]
376 *
377 * Create an ItemIDList from a path
378 *
379 * PARAMS
380 * path [I]
381 * ppidl [O]
382 * attributes [I/O] requested attributes on call and actual attributes when
383 * the function returns
384 *
385 * RETURNS
386 * NO_ERROR if successful, or an OLE errer code otherwise
387 *
388 * NOTES
389 * Wrapper for IShellFolder_ParseDisplayName().
390 */
392{
393 WCHAR lpszDisplayName[MAX_PATH];
394
395 TRACE_(shell)("%s %p 0x%08x\n", path, ppidl, attributes ? *attributes : 0);
396
397 if (!MultiByteToWideChar(CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH))
398 lpszDisplayName[MAX_PATH-1] = 0;
399
400 return SHILCreateFromPathW(lpszDisplayName, ppidl, attributes);
401}
402
404{
405 LPSHELLFOLDER sf;
406 DWORD pchEaten;
408
409 TRACE_(shell)("%s %p 0x%08x\n", debugstr_w(path), ppidl, attributes ? *attributes : 0);
410
411 if (SUCCEEDED (SHGetDesktopFolder(&sf)))
412 {
413 ret = IShellFolder_ParseDisplayName(sf, 0, NULL, (LPWSTR)path, &pchEaten, ppidl, attributes);
414 IShellFolder_Release(sf);
415 }
416 return ret;
417}
418
420{
421 if ( SHELL_OsIsUnicode())
422 return SHILCreateFromPathW (path, ppidl, attributes);
423 return SHILCreateFromPathA (path, ppidl, attributes);
424}
425
426/*************************************************************************
427 * SHCloneSpecialIDList [SHELL32.89]
428 *
429 * Create an ItemIDList to one of the special folders.
430
431 * PARAMS
432 * hwndOwner [in]
433 * nFolder [in] CSIDL_xxxxx
434 * fCreate [in] Create folder if it does not exist
435 *
436 * RETURNS
437 * Success: The newly created pidl
438 * Failure: NULL, if inputs are invalid.
439 *
440 * NOTES
441 * exported by ordinal.
442 * Caller is responsible for deallocating the returned ItemIDList with the
443 * shells IMalloc interface, aka ILFree.
444 */
446{
447 LPITEMIDLIST ppidl;
448 TRACE_(shell)("(hwnd=%p,csidl=0x%x,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F");
449
450 if (fCreate)
452
453 SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl);
454 return ppidl;
455}
456
457/*************************************************************************
458 * ILGlobalClone [SHELL32.20]
459 *
460 * Clones an ItemIDList using Alloc.
461 *
462 * PARAMS
463 * pidl [I] ItemIDList to clone
464 *
465 * RETURNS
466 * Newly allocated ItemIDList.
467 *
468 * NOTES
469 * exported by ordinal.
470 */
472{
473 DWORD len;
474 LPITEMIDLIST newpidl;
475
476 if (!pidl)
477 return NULL;
478
479 len = ILGetSize(pidl);
480 newpidl = Alloc(len);
481 if (newpidl)
482 memcpy(newpidl,pidl,len);
483
484 TRACE("pidl=%p newpidl=%p\n",pidl, newpidl);
485 pdump(pidl);
486
487 return newpidl;
488}
489
490#ifdef __REACTOS__
491static inline LPITEMIDLIST _ILUnsafeNext(LPCITEMIDLIST pidl)
492{
493 return (LPITEMIDLIST)(((BYTE*)pidl) + pidl->mkid.cb);
494}
495
497{
498 for (UINT i = 0;; ++i)
499 {
500 if (!pidl || !pidl->mkid.cb)
501 return i;
502 pidl = _ILUnsafeNext(pidl);
503 }
504}
505
506static BOOL _ILMemCmpEqualIDList(LPCITEMIDLIST p1, LPCITEMIDLIST p2)
507{
508 for (;; p1 = _ILUnsafeNext(p1), p2 = _ILUnsafeNext(p2))
509 {
510 DWORD cb1 = p1 ? p1->mkid.cb : 0x80000000; /* Empty != NULL */
511 DWORD cb2 = p2 ? p2->mkid.cb : 0x80000000;
512 if (cb1 != cb2)
513 return FALSE;
514 if (LOWORD(cb1) == 0)
515 return cb1 == cb2;
516 if (memcmp(p1, p2, cb1))
517 return FALSE;
518 }
519}
520#else /* __REACTOS__ */
522{
523 LPPIDLDATA pdata1 = _ILGetDataPointer(pidltemp1);
524 LPPIDLDATA pdata2 = _ILGetDataPointer(pidltemp2);
525
526 IID *iid1 = _ILGetGUIDPointer(pidltemp1);
527 IID *iid2 = _ILGetGUIDPointer(pidltemp2);
528
529 FileStructW* pDataW1 = _ILGetFileStructW(pidltemp1);
530 FileStructW* pDataW2 = _ILGetFileStructW(pidltemp2);
531
532 if (_ILIsDesktop(pidltemp1) && _ILIsDesktop(pidltemp2))
533 {
534 return TRUE;
535 }
536 else if (_ILIsDesktop(pidltemp1) || _ILIsDesktop(pidltemp2))
537 {
538 return FALSE;
539 }
540 else if (iid1 || iid2)
541 {
542 if (!iid1 || !iid2 || memcmp(iid1, iid2, sizeof(GUID)))
543 return FALSE;
544 }
545 else if (pDataW1 || pDataW2)
546 {
547 if (!pDataW1 || !pDataW2 || wcsicmp(pDataW1->wszName, pDataW2->wszName))
548 return FALSE;
549 }
550 else if (_ILIsFolder(pidltemp1) || _ILIsFolder(pidltemp2))
551 {
552 if (!_ILIsFolder(pidltemp1) || !_ILIsFolder(pidltemp2) || strcmp(pdata1->u.file.szNames, pdata2->u.file.szNames))
553 return FALSE;
554 }
555 else if (_ILIsValue(pidltemp1) || _ILIsValue(pidltemp2))
556 {
557 if (!_ILIsValue(pidltemp1) || !_ILIsValue(pidltemp2) || strcmp(pdata1->u.file.szNames, pdata2->u.file.szNames))
558 return FALSE;
559 }
560 else if (_ILIsDrive(pidltemp1) || _ILIsDrive(pidltemp2))
561 {
562 if (!_ILIsDrive(pidltemp1) || !_ILIsDrive(pidltemp2) || pdata1->u.drive.szDriveName[0] != pdata2->u.drive.szDriveName[0])
563 return FALSE;
564 }
565 else
566 {
567 if ((pidltemp1->mkid.cb != pidltemp2->mkid.cb) ||
568 !RtlEqualMemory((BYTE*)&pidltemp1->mkid, (BYTE*)&pidltemp2->mkid, pidltemp1->mkid.cb))
569 {
570 return FALSE;
571 }
572 }
573
574 return TRUE;
575}
576#endif /* __REACTOS__ */
577
578/*************************************************************************
579 * ILIsEqual [SHELL32.21]
580 *
581 */
583{
584 LPCITEMIDLIST pidltemp1 = pidl1;
585 LPCITEMIDLIST pidltemp2 = pidl2;
586
587 TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2);
588
589#ifdef __REACTOS__
590 IShellFolder *psfDesktop;
591 UINT depth1;
592
593 if (pidl1 == pidl2 || _ILMemCmpEqualIDList(pidltemp1, pidltemp2))
594 return TRUE;
595
596 depth1 = _ILGetDepth(pidl1);
597 if (depth1 && depth1 == _ILGetDepth(pidl2) && SUCCEEDED(SHGetDesktopFolder(&psfDesktop)))
598 {
599 HRESULT hr = IShellFolder_CompareIDs(psfDesktop, SHCIDS_CANONICALONLY, pidl1, pidl2);
600 IShellFolder_Release(psfDesktop);
601 return hr == 0;
602 }
603#else /* __REACTOS__ */
604 /*
605 * Explorer reads from registry directly (StreamMRU),
606 * so we can only check here
607 */
608 if (!pcheck(pidl1) || !pcheck (pidl2))
609#ifdef __REACTOS__
610 {
611 /* We don't understand the PIDL content but that does not mean it's invalid */
612 }
613#else
614 return FALSE;
615#endif
616
617 pdump (pidl1);
618 pdump (pidl2);
619
620 if (!pidl1 || !pidl2)
621 return FALSE;
622
623 while (pidltemp1->mkid.cb && pidltemp2->mkid.cb)
624 {
625 if (!_ILHACKCompareSimpleIds(pidltemp1, pidltemp2))
626 return FALSE;
627
628 pidltemp1 = ILGetNext(pidltemp1);
629 pidltemp2 = ILGetNext(pidltemp2);
630 }
631
632 if (!pidltemp1->mkid.cb && !pidltemp2->mkid.cb)
633 return TRUE;
634#endif /* __REACTOS__ */
635 return FALSE;
636}
637
639{
640 LPCITEMIDLIST pParentRoot = pidlParent, pChildRoot = pidlChild, pResult = NULL;
641 LPITEMIDLIST pidl;
642 SIZE_T cb = 0;
643
644 if (!pidlParent || !pidlChild)
645 return pResult;
646
647 while (pidlParent->mkid.cb)
648 {
649 cb += pidlChild->mkid.cb;
650 if (!pidlChild->mkid.cb)
651 {
652 if (pidlParent->mkid.cb)
653 return pResult; /* The child is shorter than the parent */
654 else
655 break;
656 }
657 pidlChild = _ILUnsafeNext(pidlChild);
658 pidlParent = _ILUnsafeNext(pidlParent);
659 }
660
661 if (bImmediate && (!pidlChild->mkid.cb || _ILUnsafeNext(pidlChild)->mkid.cb))
662 return pResult; /* Same as parent or a deeper grandchild */
663
664 if ((pidl = SHAlloc(cb + sizeof(WORD))) != NULL)
665 {
666 CopyMemory(pidl, pChildRoot, cb);
667 ZeroMemory((BYTE*)pidl + cb, sizeof(WORD));
668 if (ILIsEqual(pParentRoot, pidl))
669 pResult = pidlChild;
670 ILFree(pidl);
671 }
672 return pResult;
673}
674
675/*************************************************************************
676 * ILIsParent [SHELL32.23]
677 *
678 * Verifies that pidlParent is indeed the (immediate) parent of pidlChild.
679 *
680 * PARAMS
681 * pidlParent [I]
682 * pidlChild [I]
683 * bImmediate [I] only return true if the parent is the direct parent
684 * of the child
685 *
686 * RETURNS
687 * True if the parent ItemIDlist is a complete part of the child ItemIdList,
688 * False otherwise.
689 *
690 * NOTES
691 * parent = a/b, child = a/b/c -> true, c is in folder a/b
692 * child = a/b/c/d -> false if bImmediate is true, d is not in folder a/b
693 * child = a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b
694 * child = a/b -> false if bImmediate is true
695 * child = a/b -> true if bImmediate is false
696 */
697BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
698{
699 LPCITEMIDLIST pParent = pidlParent;
700 LPCITEMIDLIST pChild = pidlChild;
701
702 TRACE("%p %p %x\n", pidlParent, pidlChild, bImmediate);
703
704#ifdef __REACTOS__
705 return _ILIsParentEx(pParent, pChild, bImmediate) != NULL;
706#else /* __REACTOS__ */
707 if (!pParent || !pChild)
708 return FALSE;
709
710 while (pParent->mkid.cb && pChild->mkid.cb)
711 {
712 if (!_ILHACKCompareSimpleIds(pParent, pChild))
713 return FALSE;
714
716 pChild = ILGetNext(pChild);
717 }
718
719 /* child has shorter name than parent */
720 if (pParent->mkid.cb)
721 return FALSE;
722
723 /* not immediate descent */
724 if ((!pChild->mkid.cb || ILGetNext(pChild)->mkid.cb) && bImmediate)
725 return FALSE;
726
727 return TRUE;
728#endif /* __REACTOS__ */
729}
730
731/*************************************************************************
732 * ILFindChild [SHELL32.24]
733 *
734 * Compares elements from pidl1 and pidl2.
735 *
736 * PARAMS
737 * pidl1 [I]
738 * pidl2 [I]
739 *
740 * RETURNS
741 * pidl1 is desktop pidl2
742 * pidl1 shorter pidl2 pointer to first different element of pidl2
743 * if there was at least one equal element
744 * pidl2 shorter pidl1 0
745 * pidl2 equal pidl1 pointer to last 0x00-element of pidl2
746 *
747 * NOTES
748 * exported by ordinal.
749 */
751{
752#ifdef __REACTOS__
753 TRACE("pidl1=%p pidl2=%p\n", pidl1, pidl2);
754
755 if (_ILIsDesktop(pidl1))
756 return (PUIDLIST_RELATIVE)pidl2;
757 return (PUIDLIST_RELATIVE)_ILIsParentEx(pidl1, pidl2, FALSE);
758#else /* __REACTOS__ */
759 LPCITEMIDLIST pidltemp1 = pidl1;
760 LPCITEMIDLIST pidltemp2 = pidl2;
762
763 TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2);
764
765 /* explorer reads from registry directly (StreamMRU),
766 so we can only check here */
767 if ((!pcheck (pidl1)) || (!pcheck (pidl2)))
768 return FALSE;
769
770 pdump (pidl1);
771 pdump (pidl2);
772
773 if (_ILIsDesktop(pidl1))
774 {
775 ret = pidl2;
776 }
777 else
778 {
779 while (pidltemp1->mkid.cb && pidltemp2->mkid.cb)
780 {
781 if (!_ILHACKCompareSimpleIds(pidltemp1, pidltemp2))
782 return FALSE;
783
784 pidltemp1 = ILGetNext(pidltemp1);
785 pidltemp2 = ILGetNext(pidltemp2);
786 ret = pidltemp2;
787 }
788
789 if (pidltemp1->mkid.cb)
790 ret = NULL; /* elements of pidl1 left*/
791 }
792 TRACE_(shell)("--- %p\n", ret);
793 return (PUIDLIST_RELATIVE)ret; /* pidl 1 is shorter */
794#endif /* __REACTOS__ */
795}
796
797/*************************************************************************
798 * ILCombine [SHELL32.25]
799 *
800 * Concatenates two complex ItemIDLists.
801 *
802 * PARAMS
803 * pidl1 [I] first complex ItemIDLists
804 * pidl2 [I] complex ItemIDLists to append
805 *
806 * RETURNS
807 * if both pidl's == NULL NULL
808 * if pidl1 == NULL cloned pidl2
809 * if pidl2 == NULL cloned pidl1
810 * otherwise new pidl with pidl2 appended to pidl1
811 *
812 * NOTES
813 * exported by ordinal.
814 * Does not destroy the passed in ItemIDLists!
815 */
817{
818 DWORD len1,len2;
819 LPITEMIDLIST pidlNew;
820
821 TRACE("pidl=%p pidl=%p\n",pidl1,pidl2);
822
823 if (!pidl1 && !pidl2) return NULL;
824
825 pdump (pidl1);
826 pdump (pidl2);
827
828 if (!pidl1)
829 {
830 pidlNew = ILClone(pidl2);
831 return pidlNew;
832 }
833
834 if (!pidl2)
835 {
836 pidlNew = ILClone(pidl1);
837 return pidlNew;
838 }
839
840 len1 = ILGetSize(pidl1)-2;
841 len2 = ILGetSize(pidl2);
842 pidlNew = SHAlloc(len1+len2);
843
844 if (pidlNew)
845 {
846 memcpy(pidlNew,pidl1,len1);
847 memcpy(((BYTE *)pidlNew)+len1,pidl2,len2);
848 }
849
850 /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/
851 return pidlNew;
852}
853
854#ifndef __REACTOS__ /* See ..\utils.cpp */
855/*************************************************************************
856 * SHGetRealIDL [SHELL32.98]
857 *
858 * NOTES
859 */
860HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal)
861{
862 IDataObject* pDataObj;
863 HRESULT hr;
864
865 hr = IShellFolder_GetUIObjectOf(lpsf, 0, 1, &pidlSimple,
866 &IID_IDataObject, 0, (LPVOID*)&pDataObj);
867 if (SUCCEEDED(hr))
868 {
869 STGMEDIUM medium;
870 FORMATETC fmt;
871
873 fmt.ptd = NULL;
874 fmt.dwAspect = DVASPECT_CONTENT;
875 fmt.lindex = -1;
876 fmt.tymed = TYMED_HGLOBAL;
877
878 hr = IDataObject_GetData(pDataObj, &fmt, &medium);
879
880 IDataObject_Release(pDataObj);
881
882 if (SUCCEEDED(hr))
883 {
884 /*assert(pida->cidl==1);*/
885 LPIDA pida = GlobalLock(medium.u.hGlobal);
886
887 LPCITEMIDLIST pidl_folder = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]);
888 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
889
890 *pidlReal = ILCombine(pidl_folder, pidl_child);
891
892 if (!*pidlReal)
894
895 GlobalUnlock(medium.u.hGlobal);
896 GlobalFree(medium.u.hGlobal);
897 }
898 }
899
900 return hr;
901}
902#endif
903
904/*************************************************************************
905 * SHLogILFromFSIL [SHELL32.95]
906 *
907 * NOTES
908 * pild = CSIDL_DESKTOP ret = 0
909 * pild = CSIDL_DRIVES ret = 0
910 */
912{
913 FIXME("(pidl=%p)\n",pidl);
914
915 pdump(pidl);
916
917 return 0;
918}
919
920/*************************************************************************
921 * ILGetSize [SHELL32.152]
922 *
923 * Gets the byte size of an ItemIDList including zero terminator
924 *
925 * PARAMS
926 * pidl [I] ItemIDList
927 *
928 * RETURNS
929 * size of pidl in bytes
930 *
931 * NOTES
932 * exported by ordinal
933 */
935{
936 LPCSHITEMID si;
937 UINT len=0;
938
939 if (pidl)
940 {
941 si = &(pidl->mkid);
942
943 while (si->cb)
944 {
945 len += si->cb;
946 si = (LPCSHITEMID)(((const BYTE*)si)+si->cb);
947 }
948 len += 2;
949 }
950 TRACE("pidl=%p size=%u\n",pidl, len);
951 return len;
952}
953
954/*************************************************************************
955 * ILGetNext [SHELL32.153]
956 *
957 * Gets the next ItemID of an ItemIDList
958 *
959 * PARAMS
960 * pidl [I] ItemIDList
961 *
962 * RETURNS
963 * null -> null
964 * desktop -> null
965 * simple pidl -> pointer to 0x0000 element
966 *
967 * NOTES
968 * exported by ordinal.
969 */
971{
972 WORD len;
973
974 TRACE("%p\n", pidl);
975
976 if (pidl)
977 {
978 len = pidl->mkid.cb;
979 if (len)
980 {
981 pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len);
982 TRACE("-- %p\n", pidl);
983 return (LPITEMIDLIST)pidl;
984 }
985 }
986 return NULL;
987}
988
989/*************************************************************************
990 * ILAppendID [SHELL32.154]
991 *
992 * Adds the single ItemID item to the ItemIDList indicated by pidl.
993 * If bEnd is FALSE, inserts the item in the front of the list,
994 * otherwise it adds the item to the end. (???)
995 *
996 * PARAMS
997 * pidl [I] ItemIDList to extend
998 * item [I] ItemID to prepend/append
999 * bEnd [I] Indicates if the item should be appended
1000 *
1001 * NOTES
1002 * Destroys the passed in idlist! (???)
1003 */
1005{
1006 LPITEMIDLIST idlRet;
1008
1009 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd);
1010
1011 pdump (pidl);
1012 pdump (itemid);
1013
1014 if (_ILIsDesktop(pidl))
1015 {
1016 idlRet = ILClone(itemid);
1017 SHFree (pidl);
1018 return idlRet;
1019 }
1020
1021 if (bEnd)
1022 idlRet = ILCombine(pidl, itemid);
1023 else
1024 idlRet = ILCombine(itemid, pidl);
1025
1026 SHFree(pidl);
1027 return idlRet;
1028}
1029
1030/*************************************************************************
1031 * ILFree [SHELL32.155]
1032 *
1033 * Frees memory (if not NULL) allocated by SHMalloc allocator
1034 *
1035 * PARAMS
1036 * pidl [I]
1037 *
1038 * RETURNS
1039 * Nothing
1040 *
1041 * NOTES
1042 * exported by ordinal
1043 */
1045{
1046 TRACE("(pidl=%p)\n",pidl);
1047 SHFree(pidl);
1048}
1049
1050/*************************************************************************
1051 * ILGlobalFree [SHELL32.156]
1052 *
1053 * Frees memory (if not NULL) allocated by Alloc allocator
1054 *
1055 * PARAMS
1056 * pidl [I]
1057 *
1058 * RETURNS
1059 * Nothing
1060 *
1061 * NOTES
1062 * exported by ordinal.
1063 */
1065{
1066 TRACE("%p\n", pidl);
1067
1068 Free(pidl);
1069}
1070
1071/*************************************************************************
1072 * ILCreateFromPathA [SHELL32.189]
1073 *
1074 * Creates a complex ItemIDList from a path and returns it.
1075 *
1076 * PARAMS
1077 * path [I]
1078 *
1079 * RETURNS
1080 * the newly created complex ItemIDList or NULL if failed
1081 *
1082 * NOTES
1083 * exported by ordinal.
1084 */
1086{
1087 LPITEMIDLIST pidlnew = NULL;
1088
1089 TRACE_(shell)("%s\n", debugstr_a(path));
1090
1091 if (SUCCEEDED(SHILCreateFromPathA(path, &pidlnew, NULL)))
1092 return pidlnew;
1093 return NULL;
1094}
1095
1096/*************************************************************************
1097 * ILCreateFromPathW [SHELL32.190]
1098 *
1099 * See ILCreateFromPathA.
1100 */
1102{
1103 LPITEMIDLIST pidlnew = NULL;
1104
1105 TRACE_(shell)("%s\n", debugstr_w(path));
1106
1107 if (SUCCEEDED(SHILCreateFromPathW(path, &pidlnew, NULL)))
1108 return pidlnew;
1109 return NULL;
1110}
1111
1112/*************************************************************************
1113 * ILCreateFromPath [SHELL32.157]
1114 */
1116{
1117 if ( SHELL_OsIsUnicode())
1118 return ILCreateFromPathW (path);
1119 return ILCreateFromPathA (path);
1120}
1121
1122/*************************************************************************
1123 * _ILParsePathW [internal]
1124 *
1125 * Creates an ItemIDList from a path and returns it.
1126 *
1127 * PARAMS
1128 * path [I] path to parse and convert into an ItemIDList
1129 * lpFindFile [I] pointer to buffer to initialize the FileSystem
1130 * Bind Data object with
1131 * bBindCtx [I] indicates to create a BindContext and assign a
1132 * FileSystem Bind Data object
1133 * ppidl [O] the newly create ItemIDList
1134 * prgfInOut [I/O] requested attributes on input and actual
1135 * attributes on return
1136 *
1137 * RETURNS
1138 * NO_ERROR on success or an OLE error code
1139 *
1140 * NOTES
1141 * If either lpFindFile is non-NULL or bBindCtx is TRUE, this function
1142 * creates a BindContext object and assigns a FileSystem Bind Data object
1143 * to it, passing the BindContext to IShellFolder_ParseDisplayName. Each
1144 * IShellFolder uses that FileSystem Bind Data object of the BindContext
1145 * to pass data about the current path element to the next object. This
1146 * is used to avoid having to verify the current path element on disk, so
1147 * that creating an ItemIDList from a nonexistent path still can work.
1148 */
1150 BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
1151{
1152 LPSHELLFOLDER pSF = NULL;
1153 LPBC pBC = NULL;
1154 HRESULT ret;
1155
1156 TRACE("%s %p %d (%p)->%p (%p)->0x%x\n", debugstr_w(path), lpFindFile, bBindCtx,
1157 ppidl, ppidl ? *ppidl : NULL,
1158 prgfInOut, prgfInOut ? *prgfInOut : 0);
1159
1160 ret = SHGetDesktopFolder(&pSF);
1161 if (FAILED(ret))
1162 return ret;
1163
1164 if (lpFindFile || bBindCtx)
1165 ret = IFileSystemBindData_Constructor(lpFindFile, &pBC);
1166
1167 if (SUCCEEDED(ret))
1168 {
1169 ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut);
1170 }
1171
1172 if (pBC)
1173 {
1174 IBindCtx_Release(pBC);
1175 pBC = NULL;
1176 }
1177
1178 IShellFolder_Release(pSF);
1179
1180 if (FAILED(ret) && ppidl)
1181 *ppidl = NULL;
1182
1183 TRACE("%s %p 0x%x\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0);
1184
1185 return ret;
1186}
1187
1189{
1191 LPITEMIDLIST pidl = NULL;
1192 _ILParsePathW(pszPath, &data, TRUE, &pidl, NULL);
1193 return pidl;
1194}
1195
1196/*************************************************************************
1197 * SHSimpleIDListFromPath [SHELL32.162]
1198 *
1199 * Creates a simple ItemIDList from a path and returns it. This function
1200 * does not fail on nonexistent paths.
1201 *
1202 * PARAMS
1203 * path [I] path to parse and convert into an ItemIDList
1204 *
1205 * RETURNS
1206 * the newly created simple ItemIDList
1207 *
1208 * NOTES
1209 * Simple in the name does not mean a relative ItemIDList but rather a
1210 * fully qualified list, where only the file name is filled in and the
1211 * directory flag for those ItemID elements this is known about, eg.
1212 * it is not the last element in the ItemIDList or the actual directory
1213 * exists on disk.
1214 * exported by ordinal.
1215 */
1217{
1218 LPITEMIDLIST pidl = NULL;
1219 LPWSTR wPath = NULL;
1220 int len;
1221
1222 TRACE("%s\n", debugstr_a(lpszPath));
1223
1224 if (lpszPath)
1225 {
1226 len = MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, NULL, 0);
1227 wPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1228 MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, wPath, len);
1229 }
1230
1231 _ILParsePathW(wPath, NULL, TRUE, &pidl, NULL);
1232
1233 HeapFree(GetProcessHeap(), 0, wPath);
1234 TRACE("%s %p\n", debugstr_a(lpszPath), pidl);
1235 return pidl;
1236}
1237
1239{
1240 LPITEMIDLIST pidl = NULL;
1241
1242 TRACE("%s\n", debugstr_w(lpszPath));
1243
1244 _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL);
1245
1246 TRACE("%s %p\n", debugstr_w(lpszPath), pidl);
1247 return pidl;
1248}
1249
1251{
1252 if ( SHELL_OsIsUnicode())
1253 return SHSimpleIDListFromPathW (lpszPath);
1254 return SHSimpleIDListFromPathA (lpszPath);
1255}
1256
1257/*************************************************************************
1258 * SHGetDataFromIDListA [SHELL32.247]
1259 *
1260 * NOTES
1261 * the pidl can be a simple one. since we can't get the path out of the pidl
1262 * we have to take all data from the pidl
1263 */
1265 int nFormat, LPVOID dest, int len)
1266{
1267 LPSTR filename, shortname;
1269
1270 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
1271
1272 pdump(pidl);
1273 if (!psf || !dest)
1274 return E_INVALIDARG;
1275
1276 switch (nFormat)
1277 {
1278 case SHGDFIL_FINDDATA:
1279 pfd = dest;
1280
1281 if (_ILIsDrive(pidl) || _ILIsSpecialFolder(pidl))
1282 return E_INVALIDARG;
1283
1284 if (len < sizeof(WIN32_FIND_DATAA))
1285 return E_INVALIDARG;
1286
1287 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
1288 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1289 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1290 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1291
1293 shortname = _ILGetSTextPointer(pidl);
1294
1295 if (filename)
1296 lstrcpynA(pfd->cFileName, filename, sizeof(pfd->cFileName));
1297 else
1298 pfd->cFileName[0] = '\0';
1299
1300 if (shortname)
1301 lstrcpynA(pfd->cAlternateFileName, shortname, sizeof(pfd->cAlternateFileName));
1302 else
1303 pfd->cAlternateFileName[0] = '\0';
1304 return S_OK;
1305
1308 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1309 break;
1310
1311 default:
1312 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1313 }
1314
1315 return E_INVALIDARG;
1316}
1317
1318/*************************************************************************
1319 * SHGetDataFromIDListW [SHELL32.248]
1320 *
1321 */
1323 int nFormat, LPVOID dest, int len)
1324{
1325 LPSTR filename, shortname;
1327
1328 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
1329
1330 pdump(pidl);
1331
1332 if (!psf || !dest)
1333 return E_INVALIDARG;
1334
1335 switch (nFormat)
1336 {
1337 case SHGDFIL_FINDDATA:
1338 pfd = dest;
1339
1340 if (_ILIsDrive(pidl))
1341 return E_INVALIDARG;
1342
1343 if (len < sizeof(WIN32_FIND_DATAW))
1344 return E_INVALIDARG;
1345
1346 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAW));
1347 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1348 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1349 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1350
1352 shortname = _ILGetSTextPointer(pidl);
1353
1354 if (!filename)
1355 pfd->cFileName[0] = '\0';
1356 else if (!MultiByteToWideChar(CP_ACP, 0, filename, -1, pfd->cFileName, MAX_PATH))
1357 pfd->cFileName[MAX_PATH-1] = 0;
1358
1359 if (!shortname)
1360 pfd->cAlternateFileName[0] = '\0';
1361 else if (!MultiByteToWideChar(CP_ACP, 0, shortname, -1, pfd->cAlternateFileName, 14))
1362 pfd->cAlternateFileName[13] = 0;
1363 return S_OK;
1364
1367 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1368 break;
1369
1370 default:
1371 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1372 }
1373
1374 return E_INVALIDARG;
1375}
1376
1377/*************************************************************************
1378 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
1379 *
1380 * PARAMETERS
1381 * pidl, [IN] pidl
1382 * pszPath [OUT] path
1383 *
1384 * RETURNS
1385 * path from a passed PIDL.
1386 *
1387 * NOTES
1388 * NULL returns FALSE
1389 * desktop pidl gives path to desktop directory back
1390 * special pidls returning FALSE
1391 */
1393{
1394 WCHAR wszPath[MAX_PATH];
1395 BOOL bSuccess;
1396
1397 bSuccess = SHGetPathFromIDListW(pidl, wszPath);
1398 WideCharToMultiByte(CP_ACP, 0, wszPath, -1, pszPath, MAX_PATH, NULL, NULL);
1399
1400 return bSuccess;
1401}
1402
1403/*************************************************************************
1404 * SHGetPathFromIDListW [SHELL32.@]
1405 *
1406 * See SHGetPathFromIDListA.
1407 */
1410 _In_ LPCITEMIDLIST pidl,
1411 _Out_writes_(cchPathMax) LPWSTR pszPath,
1412 _In_ SIZE_T cchPathMax)
1413{
1414 HRESULT hr;
1415 LPCITEMIDLIST pidlLast;
1416 LPSHELLFOLDER psfFolder;
1418 STRRET strret;
1419
1420 TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
1421 pdump(pidl);
1422
1423 *pszPath = UNICODE_NULL;
1424 if (!pidl)
1425 return E_FAIL;
1426
1427 hr = SHBindToParent(pidl, &IID_IShellFolder, (VOID**)&psfFolder, &pidlLast);
1428 if (FAILED(hr))
1429 {
1430 ERR("SHBindToParent failed: %x\n", hr);
1431 return hr;
1432 }
1433
1434 dwAttributes = SFGAO_FILESYSTEM;
1435 hr = IShellFolder_GetAttributesOf(psfFolder, 1, &pidlLast, &dwAttributes);
1436 if (FAILED(hr) || !(dwAttributes & SFGAO_FILESYSTEM))
1437 {
1438 WARN("Wrong dwAttributes or GetAttributesOf failed: %x\n", hr);
1439 IShellFolder_Release(psfFolder);
1440 return E_FAIL;
1441 }
1442
1443 hr = IShellFolder_GetDisplayNameOf(psfFolder, pidlLast, SHGDN_FORPARSING, &strret);
1444 IShellFolder_Release(psfFolder);
1445 if (FAILED(hr))
1446 return hr;
1447
1448 hr = StrRetToBufW(&strret, pidlLast, pszPath, cchPathMax);
1449
1450 TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(pszPath), hr);
1451 return hr;
1452}
1453
1455{
1456 return SUCCEEDED(SHGetPathCchFromIDListW(pidl, pszPath, MAX_PATH));
1457}
1458
1459/*************************************************************************
1460 * SHBindToParent [shell version 5.0]
1461 */
1463{
1464 IShellFolder * psfDesktop;
1466
1467 TRACE_(shell)("pidl=%p\n", pidl);
1468 pdump(pidl);
1469
1470 if (!pidl || !ppv)
1471 return E_INVALIDARG;
1472
1473 *ppv = NULL;
1474 if (ppidlLast)
1475 *ppidlLast = NULL;
1476
1477 hr = SHGetDesktopFolder(&psfDesktop);
1478 if (FAILED(hr))
1479 return hr;
1480
1481 if (_ILIsPidlSimple(pidl))
1482 {
1483 /* we are on desktop level */
1484 hr = IShellFolder_QueryInterface(psfDesktop, riid, ppv);
1485 }
1486 else
1487 {
1488 LPITEMIDLIST pidlParent = ILClone(pidl);
1489 ILRemoveLastID(pidlParent);
1490 hr = IShellFolder_BindToObject(psfDesktop, pidlParent, NULL, riid, ppv);
1491 SHFree (pidlParent);
1492 }
1493
1494 IShellFolder_Release(psfDesktop);
1495
1496 if (SUCCEEDED(hr) && ppidlLast)
1497 *ppidlLast = ILFindLastID(pidl);
1498
1499 TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08x\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr);
1500 return hr;
1501}
1502
1503/*************************************************************************
1504 * SHParseDisplayName [shell version 6.0]
1505 */
1507 LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
1508{
1509 HRESULT hr;
1510 LPWSTR pszNameDup;
1511 IShellFolder *psfDesktop;
1512 IBindCtx *pBindCtx = NULL;
1513
1514 TRACE("(%s, %p, %p, 0x%X, %p)\n", pszName, pbc, ppidl, sfgaoIn, psfgaoOut);
1515
1516 *ppidl = NULL;
1517
1518 if (psfgaoOut)
1519 *psfgaoOut = 0;
1520
1521 pszNameDup = StrDupW(pszName);
1522 if (!pszNameDup)
1523 return E_OUTOFMEMORY;
1524
1525 psfDesktop = NULL;
1526 hr = SHGetDesktopFolder(&psfDesktop);
1527 if (FAILED(hr))
1528 {
1529 LocalFree(pszNameDup);
1530 return hr;
1531 }
1532
1533 if (!pbc)
1534 {
1535 hr = BindCtx_RegisterObjectParam(NULL, STR_PARSE_TRANSLATE_ALIASES, NULL, &pBindCtx);
1536 pbc = pBindCtx;
1537 }
1538
1539 if (SUCCEEDED(hr))
1540 {
1541 ULONG sfgao = sfgaoIn, cchEaten;
1542 HWND hwndUI = BindCtx_GetUIWindow(pbc);
1543 hr = psfDesktop->lpVtbl->ParseDisplayName(psfDesktop,
1544 hwndUI,
1545 pbc,
1546 pszNameDup,
1547 &cchEaten,
1548 ppidl,
1549 (psfgaoOut ? &sfgao : NULL));
1550 if (SUCCEEDED(hr) && psfgaoOut)
1551 *psfgaoOut = (sfgao & sfgaoIn);
1552 }
1553
1554 LocalFree(pszNameDup);
1555
1556 if (psfDesktop)
1557 psfDesktop->lpVtbl->Release(psfDesktop);
1558
1559 if (pBindCtx)
1560 pBindCtx->lpVtbl->Release(pBindCtx);
1561
1562 return hr;
1563}
1564
1565/*************************************************************************
1566 * SHGetNameFromIDList [SHELL32.@]
1567 */
1569{
1570 IShellFolder *psfparent;
1571 LPCITEMIDLIST child_pidl;
1572 STRRET disp_name;
1573 HRESULT ret;
1574
1575 TRACE("%p 0x%08x %p\n", pidl, sigdnName, ppszName);
1576
1577 *ppszName = NULL;
1578 ret = SHBindToParent(pidl, &IID_IShellFolder, (void**)&psfparent, &child_pidl);
1579 if(SUCCEEDED(ret))
1580 {
1581 switch(sigdnName)
1582 {
1583 /* sigdnName & 0xffff */
1584 case SIGDN_NORMALDISPLAY: /* SHGDN_NORMAL */
1585 case SIGDN_PARENTRELATIVEPARSING: /* SHGDN_INFOLDER | SHGDN_FORPARSING */
1586 case SIGDN_PARENTRELATIVEEDITING: /* SHGDN_INFOLDER | SHGDN_FOREDITING */
1587 case SIGDN_DESKTOPABSOLUTEPARSING: /* SHGDN_FORPARSING */
1588 case SIGDN_DESKTOPABSOLUTEEDITING: /* SHGDN_FOREDITING | SHGDN_FORADDRESSBAR*/
1589 case SIGDN_PARENTRELATIVEFORADDRESSBAR: /* SIGDN_INFOLDER | SHGDN_FORADDRESSBAR */
1590 case SIGDN_PARENTRELATIVE: /* SIGDN_INFOLDER */
1591
1592 disp_name.uType = STRRET_WSTR;
1593 ret = IShellFolder_GetDisplayNameOf(psfparent, child_pidl,
1594 sigdnName & 0xffff,
1595 &disp_name);
1596 if(SUCCEEDED(ret))
1597 ret = StrRetToStrW(&disp_name, pidl, ppszName);
1598
1599 break;
1600
1601 case SIGDN_FILESYSPATH:
1603 if(SHGetPathFromIDListW(pidl, *ppszName))
1604 {
1605 TRACE("Got string %s\n", debugstr_w(*ppszName));
1606 ret = S_OK;
1607 }
1608 else
1609 {
1611 ret = E_INVALIDARG;
1612 }
1613 break;
1614
1615 case SIGDN_URL:
1616 default:
1617 FIXME("Unsupported SIGDN %x\n", sigdnName);
1618 ret = E_FAIL;
1619 }
1620
1621 IShellFolder_Release(psfparent);
1622 }
1623 return ret;
1624}
1625
1626/*************************************************************************
1627 * SHGetItemFromDataObject [SHELL32.@]
1628 */
1630 REFIID riid, void **ppv)
1631{
1632 return E_NOTIMPL; // FIXME
1633}
1634
1635/*************************************************************************
1636 * SHGetIDListFromObject [SHELL32.@]
1637 */
1639{
1640 IPersistIDList *ppersidl;
1641 IPersistFolder2 *ppf2;
1642 IDataObject *pdo;
1643 IFolderView *pfv;
1644 HRESULT ret;
1645
1646 if(!punk)
1647 return E_NOINTERFACE;
1648
1649 *ppidl = NULL;
1650
1651 /* Try IPersistIDList */
1652 ret = IUnknown_QueryInterface(punk, &IID_IPersistIDList, (void**)&ppersidl);
1653 if(SUCCEEDED(ret))
1654 {
1655 TRACE("IPersistIDList (%p)\n", ppersidl);
1656 ret = IPersistIDList_GetIDList(ppersidl, ppidl);
1657 IPersistIDList_Release(ppersidl);
1658 if(SUCCEEDED(ret))
1659 return ret;
1660 }
1661
1662 /* Try IPersistFolder2 */
1663 ret = IUnknown_QueryInterface(punk, &IID_IPersistFolder2, (void**)&ppf2);
1664 if(SUCCEEDED(ret))
1665 {
1666 TRACE("IPersistFolder2 (%p)\n", ppf2);
1667 ret = IPersistFolder2_GetCurFolder(ppf2, ppidl);
1668 IPersistFolder2_Release(ppf2);
1669 if(SUCCEEDED(ret))
1670 return ret;
1671 }
1672
1673 /* Try IDataObject */
1674 ret = IUnknown_QueryInterface(punk, &IID_IDataObject, (void**)&pdo);
1675 if(SUCCEEDED(ret))
1676 {
1677 IShellItem *psi;
1678 TRACE("IDataObject (%p)\n", pdo);
1680 &IID_IShellItem, (void**)&psi);
1681 if(SUCCEEDED(ret))
1682 {
1683 ret = SHGetIDListFromObject((IUnknown*)psi, ppidl);
1684 IShellItem_Release(psi);
1685 }
1686 IDataObject_Release(pdo);
1687
1688 if(SUCCEEDED(ret))
1689 return ret;
1690 }
1691
1692 /* Try IFolderView */
1693 ret = IUnknown_QueryInterface(punk, &IID_IFolderView, (void**)&pfv);
1694 if(SUCCEEDED(ret))
1695 {
1696 IShellFolder *psf;
1697 TRACE("IFolderView (%p)\n", pfv);
1698 ret = IFolderView_GetFolder(pfv, &IID_IShellFolder, (void**)&psf);
1699 if(SUCCEEDED(ret))
1700 {
1701 /* We might be able to get IPersistFolder2 from a shellfolder. */
1702 ret = SHGetIDListFromObject((IUnknown*)psf, ppidl);
1703 }
1704 IFolderView_Release(pfv);
1705 return ret;
1706 }
1707
1708 return ret;
1709}
1710
1711/**************************************************************************
1712 *
1713 * internal functions
1714 *
1715 * ### 1. section creating pidls ###
1716 *
1717 *************************************************************************
1718 */
1719
1720/* Basic PIDL constructor. Allocates size + 5 bytes, where:
1721 * - two bytes are SHITEMID.cb
1722 * - one byte is PIDLDATA.type
1723 * - two bytes are the NULL PIDL terminator
1724 * Sets type of the returned PIDL to type.
1725 */
1727{
1728 LPITEMIDLIST pidlOut = NULL;
1729
1730 pidlOut = SHAlloc(size + 5);
1731 if(pidlOut)
1732 {
1734 LPITEMIDLIST pidlNext;
1735
1736 ZeroMemory(pidlOut, size + 5);
1737 pidlOut->mkid.cb = size + 3;
1738
1739 pData = _ILGetDataPointer(pidlOut);
1740 if (pData)
1741 pData->type = type;
1742
1743 pidlNext = ILGetNext(pidlOut);
1744 if (pidlNext)
1745 pidlNext->mkid.cb = 0x00;
1746 TRACE("-- (pidl=%p, size=%u)\n", pidlOut, size);
1747 }
1748
1749 return pidlOut;
1750}
1751
1753{
1755
1756 TRACE("()\n");
1757 ret = SHAlloc(2);
1758 if (ret)
1759 ret->mkid.cb = 0;
1760 return ret;
1761}
1762
1764{
1765 TRACE("()\n");
1766 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_MyComputer);
1767}
1768
1770{
1771 TRACE("()\n");
1772 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_MyDocuments);
1773}
1774
1776{
1777 TRACE("()\n");
1778 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_Internet);
1779}
1780
1782{
1784
1785 TRACE("()\n");
1786 if (parent)
1787 {
1788 LPITEMIDLIST cpl = _ILCreateGuid(PT_COMPUTER_REGITEM, &CLSID_ControlPanel);
1789 if (cpl)
1790 {
1791 ret = ILCombine(parent, cpl);
1792 SHFree(cpl);
1793 }
1794 SHFree(parent);
1795 }
1796 return ret;
1797}
1798
1800{
1801#ifdef __REACTOS__
1802 // Note: Wine returns the PIDL as it was in Windows 95, NT5 moved it into CSIDL_CONTROLS
1803 extern HRESULT SHGetFolderLocationHelper(HWND hwnd, int nFolder, REFCLSID clsid, LPITEMIDLIST *ppidl);
1804 LPITEMIDLIST pidl;
1805 SHGetFolderLocationHelper(NULL, CSIDL_CONTROLS, &CLSID_Printers, &pidl);
1806 return pidl;
1807#else
1808 LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL;
1809
1810 TRACE("()\n");
1811 if (parent)
1812 {
1813 LPITEMIDLIST printers = _ILCreateGuid(PT_YAGUID, &CLSID_Printers);
1814
1815 if (printers)
1816 {
1817 ret = ILCombine(parent, printers);
1818 SHFree(printers);
1819 }
1820 SHFree(parent);
1821 }
1822 return ret;
1823#endif
1824}
1825
1827{
1828 TRACE("()\n");
1829 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_NetworkPlaces);
1830}
1831
1833{
1834 TRACE("()\n");
1835 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_RecycleBin);
1836}
1837
1839{
1840 TRACE("()\n");
1842}
1843
1845{
1846 LPITEMIDLIST pidlOut;
1847
1848 if (type == PT_SHELLEXT || type == PT_GUID || type == PT_YAGUID)
1849 {
1850 pidlOut = _ILAlloc(type, sizeof(GUIDStruct));
1851 if (pidlOut)
1852 {
1854
1855 pData->u.guid.guid = *guid;
1856 TRACE("-- create GUID-pidl %s\n",
1857 debugstr_guid(&(pData->u.guid.guid)));
1858 }
1859 }
1860 else
1861 {
1862 WARN("%d: invalid type for GUID\n", type);
1863 pidlOut = NULL;
1864 }
1865 return pidlOut;
1866}
1867
1868#ifndef __REACTOS__
1870{
1871 IID iid;
1872
1873 if (FAILED(SHCLSIDFromStringA(szGUID, &iid)))
1874 {
1875 ERR("%s is not a GUID\n", szGUID);
1876 return NULL;
1877 }
1878 return _ILCreateGuid(PT_GUID, &iid);
1879}
1880
1882{
1883 IID iid;
1884
1885#ifndef __REACTOS__
1886 if (FAILED(SHCLSIDFromStringW(szGUID, &iid)))
1887#else
1888 if (!GUIDFromStringW(szGUID, &iid))
1889#endif
1890 {
1891 ERR("%s is not a GUID\n", debugstr_w(szGUID));
1892 return NULL;
1893 }
1894 return _ILCreateGuid(PT_GUID, &iid);
1895}
1896#endif /* __REACTOS__ */
1897
1899{
1900 char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */
1901 DWORD len, len1, wlen, alen;
1902 LPITEMIDLIST pidl;
1903 PIDLTYPE type;
1904
1905 if (!wfd)
1906 return NULL;
1907
1908 TRACE("(%s, %s)\n",debugstr_w(wfd->cAlternateFileName), debugstr_w(wfd->cFileName));
1909
1910 /* prepare buffer with both names */
1911 len = WideCharToMultiByte(CP_ACP,0,wfd->cFileName,-1,buff,MAX_PATH,NULL,NULL);
1912 len1 = WideCharToMultiByte(CP_ACP,0,wfd->cAlternateFileName,-1, buff+len, sizeof(buff)-len, NULL, NULL);
1913 alen = len + len1;
1914
1915 type = (wfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? PT_FOLDER : PT_VALUE;
1916
1917 wlen = lstrlenW(wfd->cFileName) + 1;
1918 pidl = _ILAlloc(type, FIELD_OFFSET(FileStruct, szNames[alen + (alen & 1)]) +
1919 FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD));
1920 if (pidl)
1921 {
1923 FileStruct *fs = &pData->u.file;
1924 FileStructW *fsw;
1925 WORD *pOffsetW;
1926
1927 FileTimeToDosDateTime( &wfd->ftLastWriteTime, &fs->uFileDate, &fs->uFileTime);
1928 fs->dwFileSize = wfd->nFileSizeLow;
1929 fs->uFileAttribs = wfd->dwFileAttributes;
1930 memcpy(fs->szNames, buff, alen);
1931
1932 fsw = (FileStructW*)(pData->u.file.szNames + alen + (alen & 0x1));
1933 fsw->cbLen = FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD);
1934 FileTimeToDosDateTime( &wfd->ftCreationTime, &fsw->uCreationDate, &fsw->uCreationTime);
1935 FileTimeToDosDateTime( &wfd->ftLastAccessTime, &fsw->uLastAccessDate, &fsw->uLastAccessTime);
1936 memcpy(fsw->wszName, wfd->cFileName, wlen * sizeof(WCHAR));
1937
1938 pOffsetW = (WORD*)((LPBYTE)pidl + pidl->mkid.cb - sizeof(WORD));
1939 *pOffsetW = (LPBYTE)fsw - (LPBYTE)pidl;
1940 TRACE("-- Set Value: %s\n",debugstr_w(fsw->wszName));
1941 }
1942 return pidl;
1943
1944}
1945
1947{
1948 HANDLE hFile;
1949 WIN32_FIND_DATAW stffile;
1950
1951 if (!ppidl)
1952 return E_INVALIDARG;
1953
1954 hFile = FindFirstFileW(szPath, &stffile);
1957
1959
1960 *ppidl = _ILCreateFromFindDataW(&stffile);
1961
1962 return *ppidl ? S_OK : E_OUTOFMEMORY;
1963}
1964
1966{
1967 LPITEMIDLIST pidlOut;
1968
1969 TRACE("(%s)\n",debugstr_w(lpszNew));
1970
1971 pidlOut = _ILAlloc(PT_DRIVE, sizeof(DriveStruct));
1972 if (pidlOut)
1973 {
1974 LPSTR pszDest = _ILGetTextPointer(pidlOut);
1975 if (pszDest)
1976 {
1977 lstrcpyA(pszDest, "x:\\");
1978 pszDest[0] = toupper(lpszNew[0]);
1979 TRACE("-- create Drive: %s\n", debugstr_a(pszDest));
1980 }
1981 }
1982 return pidlOut;
1983}
1984
1986{
1987 LPITEMIDLIST pidlOut;
1988
1989 TRACE("\n");
1990
1991 pidlOut = _ILAlloc(PT_NETWORK, FIELD_OFFSET(PIDLDATA, u.network.szNames[sizeof("Entire Network")]));
1992 if (pidlOut)
1993 {
1995
1996 pData->u.network.dummy = 0;
1997 strcpy(pData->u.network.szNames, "Entire Network");
1998 }
1999 return pidlOut;
2000}
2001
2002/**************************************************************************
2003 * _ILGetDrive()
2004 *
2005 * Gets the text for the drive eg. 'c:\'
2006 *
2007 * RETURNS
2008 * strlen (lpszText)
2009 */
2011{
2012 TRACE("(%p,%p,%u)\n",pidl,pOut,uSize);
2013
2014 if(_ILIsMyComputer(pidl))
2015 pidl = ILGetNext(pidl);
2016
2017 if (pidl && _ILIsDrive(pidl))
2018 return _ILSimpleGetTextW(pidl, pOut, uSize);
2019
2020 return 0;
2021}
2022
2023/**************************************************************************
2024 *
2025 * ### 2. section testing pidls ###
2026 *
2027 **************************************************************************
2028 * _ILIsUnicode()
2029 * _ILIsDesktop()
2030 * _ILIsMyComputer()
2031 * _ILIsSpecialFolder()
2032 * _ILIsDrive()
2033 * _ILIsFolder()
2034 * _ILIsValue()
2035 * _ILIsPidlSimple()
2036 */
2038{
2039 TRACE("(%p)\n",pidl);
2040
2041 return (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG) != 0;
2042}
2043
2045{
2046 TRACE("(%p)\n",pidl);
2047
2048 return !pidl || !pidl->mkid.cb;
2049}
2050
2052{
2053 IID *iid = _ILGetGUIDPointer(pidl);
2054
2055 TRACE("(%p)\n", pidl);
2056
2057 if (iid)
2058 return IsEqualIID(iid, &CLSID_MyDocuments);
2059 return FALSE;
2060}
2061
2063{
2064 REFIID iid = _ILGetGUIDPointer(pidl);
2065
2066 TRACE("(%p)\n",pidl);
2067
2068 if (iid)
2069 return IsEqualIID(iid, &CLSID_MyComputer);
2070 return FALSE;
2071}
2072
2074{
2075 IID *iid = _ILGetGUIDPointer(pidl);
2076
2077 TRACE("(%p)\n", pidl);
2078
2079 if (iid)
2080 return IsEqualIID(iid, &CLSID_RecycleBin);
2081 return FALSE;
2082}
2083
2085{
2086 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
2087
2088 TRACE("(%p)\n",pidl);
2089
2090 return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type || PT_YAGUID == lpPData->type)) ||
2091 (pidl && pidl->mkid.cb == 0x00)
2092 ));
2093}
2094
2096{
2097 const BYTE type = _ILGetType(pidl);
2098 const BYTE fldrtype = (PT_DRIVE & PT_FOLDERTYPEMASK);
2099 return (type & PT_FOLDERTYPEMASK) == fldrtype && type != PT_COMPUTER_REGITEM;
2100}
2101
2103{
2104 /* A folder or a simple PT_FS with a child */
2105 const BYTE type = _ILGetFSType(pidl);
2106 return (type & PT_FS_FOLDER_FLAG) != 0 || (type == PT_FS && ILGetNext(pidl));
2107}
2108
2110{
2111 const BYTE type = _ILGetFSType(pidl);
2112 return type && !(type & PT_FS_FOLDER_FLAG);
2113}
2114
2116{
2117 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
2118
2119 TRACE("(%p)\n",pidl);
2120
2121 return (pidl && lpPData && (lpPData->type == 0));
2122}
2123
2124/**************************************************************************
2125 * _ILIsPidlSimple
2126 */
2128{
2129 BOOL ret = TRUE;
2130
2131 if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */
2132 {
2133 WORD len = pidl->mkid.cb;
2134 LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len );
2135
2136 if (pidlnext->mkid.cb)
2137 ret = FALSE;
2138 }
2139
2140 TRACE("%s\n", ret ? "Yes" : "No");
2141 return ret;
2142}
2143
2144/**************************************************************************
2145 *
2146 * ### 3. section getting values from pidls ###
2147 */
2148
2149/**************************************************************************
2150 * _ILSimpleGetTextW
2151 *
2152 * gets the text for the first item in the pidl (eg. simple pidl)
2153 *
2154 * returns the length of the string
2155 */
2157{
2158 DWORD dwReturn;
2159 FileStructW *pFileStructW = _ILGetFileStructW(pidl);
2160
2161 TRACE("(%p %p %x)\n",pidl,szOut,uOutSize);
2162
2163 if (pFileStructW) {
2164 lstrcpynW(szOut, pFileStructW->wszName, uOutSize);
2165 dwReturn = lstrlenW(pFileStructW->wszName);
2166 } else {
2167 GUID const * riid;
2168 WCHAR szTemp[MAX_PATH];
2169 LPSTR szSrc;
2170 LPWSTR szSrcW;
2171 dwReturn=0;
2172
2173 if (!pidl)
2174 return 0;
2175
2176 if (szOut)
2177 *szOut = 0;
2178
2179 if (_ILIsDesktop(pidl))
2180 {
2181 /* desktop */
2182 if (HCR_GetClassNameW(&CLSID_ShellDesktop, szTemp, _countof(szTemp)))
2183 {
2184 if (szOut)
2185 lstrcpynW(szOut, szTemp, uOutSize);
2186
2187 dwReturn = lstrlenW (szTemp);
2188 }
2189 }
2190 else if (( szSrcW = _ILGetTextPointerW(pidl) ))
2191 {
2192 /* unicode filesystem */
2193 if (szOut)
2194 lstrcpynW(szOut, szSrcW, uOutSize);
2195
2196 dwReturn = lstrlenW(szSrcW);
2197 }
2198 else if (( szSrc = _ILGetTextPointer(pidl) ))
2199 {
2200 /* filesystem */
2201 MultiByteToWideChar(CP_ACP, 0, szSrc, -1, szTemp, _countof(szTemp));
2202
2203 if (szOut)
2204 lstrcpynW(szOut, szTemp, uOutSize);
2205
2206 dwReturn = lstrlenW (szTemp);
2207 }
2208 else if (( riid = _ILGetGUIDPointer(pidl) ))
2209 {
2210 /* special folder */
2211 if ( HCR_GetClassNameW(riid, szTemp, _countof(szTemp)))
2212 {
2213 if (szOut)
2214 lstrcpynW(szOut, szTemp, uOutSize);
2215
2216 dwReturn = lstrlenW (szTemp);
2217 }
2218 }
2219 else
2220 {
2221 ERR("-- no text\n");
2222 }
2223 }
2224
2225 TRACE("-- (%p=%s 0x%08x)\n",szOut,debugstr_w(szOut),dwReturn);
2226 return dwReturn;
2227}
2228
2229/**************************************************************************
2230 *
2231 * ### 4. getting pointers to parts of pidls ###
2232 *
2233 **************************************************************************
2234 * _ILGetDataPointer()
2235 */
2237{
2238 if(!_ILIsEmpty(pidl))
2239 return (LPPIDLDATA)pidl->mkid.abID;
2240 return NULL;
2241}
2242
2243/**************************************************************************
2244 * _ILGetTextPointerW()
2245 * gets a pointer to the unicode long filename string stored in the pidl
2246 */
2248{
2249 /* TRACE(pidl,"(pidl%p)\n", pidl);*/
2250
2252
2253 if (!pdata)
2254 return NULL;
2255
2256 if (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG)
2257 return (LPWSTR)pdata->u.file.szNames;
2258
2259 switch (pdata->type)
2260 {
2261 case PT_GUID:
2262 case PT_SHELLEXT:
2263 case PT_YAGUID:
2264 return NULL;
2265
2266 case PT_DRIVE:
2267 case PT_DRIVE1:
2268 case PT_DRIVE2:
2269 case PT_DRIVE3:
2270 /*return (LPSTR)&(pdata->u.drive.szDriveName);*/
2271 return NULL;
2272
2273 case PT_IESPECIAL1:
2274 case PT_IESPECIAL2:
2275 /*return (LPSTR)&(pdata->u.file.szNames);*/
2276 return NULL;
2277
2278 case PT_WORKGRP:
2279 case PT_COMP:
2280 case PT_NETWORK:
2281 case PT_NETPROVIDER:
2282 case PT_SHARE:
2283 /*return (LPSTR)&(pdata->u.network.szNames);*/
2284 return NULL;
2285
2286#ifdef __REACTOS__ /* r54423 */
2287 case PT_CPLAPPLET:
2288 return pdata->u.cpanel.szName;
2289#endif
2290
2291 }
2292 return NULL;
2293}
2294
2295
2296/**************************************************************************
2297 * _ILGetTextPointer()
2298 * gets a pointer to the long filename string stored in the pidl
2299 */
2301{
2302 /* TRACE(pidl,"(pidl%p)\n", pidl);*/
2303
2304 PIDLTYPE type;
2306 if (!pdata)
2307 return NULL;
2308
2309 type = _ILGetFSType(pidl);
2310 if (type && !(type & PT_FS_UNICODE_FLAG))
2311 return pdata->u.file.szNames;
2312
2313 if (_ILIsDrive(pidl))
2314 return pdata->u.drive.szDriveName;
2315
2316 switch (pdata->type)
2317 {
2318 case PT_GUID:
2319 case PT_SHELLEXT:
2320 case PT_YAGUID:
2321 return NULL;
2322
2323 case PT_IESPECIAL1:
2324 case PT_IESPECIAL2:
2325 return pdata->u.file.szNames;
2326
2327 case PT_WORKGRP:
2328 case PT_COMP:
2329 case PT_NETWORK:
2330 case PT_NETPROVIDER:
2331 case PT_SHARE:
2332 return pdata->u.network.szNames;
2333 }
2334 return NULL;
2335}
2336
2337/**************************************************************************
2338 * _ILGetSTextPointer()
2339 * gets a pointer to the short filename string stored in the pidl
2340 */
2342{
2343 /* TRACE(pidl,"(pidl%p)\n", pidl); */
2344
2345 PIDLTYPE type;
2347 if (!pdata)
2348 return NULL;
2349
2350 type = pdata->type;
2351 if (_ILGetFSType(pidl) && !(type & PT_FS_UNICODE_FLAG))
2352 type = PT_FS;
2353
2354 switch (type)
2355 {
2356 case PT_FS:
2357 case PT_IESPECIAL1:
2358 case PT_IESPECIAL2:
2359 return pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1;
2360
2361 case PT_WORKGRP:
2362 return pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1;
2363 }
2364 return NULL;
2365}
2366
2367/**************************************************************************
2368 * _ILGetGUIDPointer()
2369 *
2370 * returns reference to guid stored in some pidls
2371 */
2373{
2375
2376 TRACE("%p\n", pidl);
2377
2378 if (!pdata)
2379 return NULL;
2380
2381 TRACE("pdata->type 0x%04x\n", pdata->type);
2382 switch (pdata->type)
2383 {
2384 case PT_SHELLEXT:
2385 case PT_GUID:
2386 case PT_YAGUID:
2387 return &(pdata->u.guid.guid);
2388
2389 default:
2390 TRACE("Unknown pidl type 0x%04x\n", pdata->type);
2391 break;
2392 }
2393 return NULL;
2394}
2395
2396/******************************************************************************
2397 * _ILGetFileStructW [Internal]
2398 *
2399 * Get pointer the a SHITEMID's FileStructW field if present
2400 *
2401 * PARAMS
2402 * pidl [I] The SHITEMID
2403 *
2404 * RETURNS
2405 * Success: Pointer to pidl's FileStructW field.
2406 * Failure: NULL
2407 */
2409 FileStructW *pFileStructW;
2410 WORD cbOffset;
2411
2412 if (!_ILIsFolderOrFile(pidl))
2413 return NULL;
2414
2415 cbOffset = *(const WORD *)((const BYTE *)pidl + pidl->mkid.cb - sizeof(WORD));
2416 pFileStructW = (FileStructW*)((LPBYTE)pidl + cbOffset);
2417
2418 /* Currently I don't see a fool prove way to figure out if a pidl is for sure of WinXP
2419 * style with a FileStructW member. If we switch all our shellfolder-implementations to
2420 * the new format, this won't be a problem. For now, we do as many sanity checks as possible. */
2421 if ((cbOffset & 0x1) || /* FileStructW member is word aligned in the pidl */
2422 /* FileStructW is positioned after FileStruct */
2423 cbOffset < sizeof(pidl->mkid.cb) + sizeof(PIDLTYPE) + sizeof(FileStruct) ||
2424 /* There has to be enough space at cbOffset in the pidl to hold FileStructW and cbOffset */
2425 cbOffset > pidl->mkid.cb - sizeof(cbOffset) - sizeof(FileStructW) ||
2426 pidl->mkid.cb != cbOffset + pFileStructW->cbLen)
2427 {
2428 WARN("Invalid pidl format (cbOffset = %d)!\n", cbOffset);
2429 return NULL;
2430 }
2431
2432 return pFileStructW;
2433}
2434
2435/*************************************************************************
2436 * _ILGetFileDateTime
2437 *
2438 * Given the ItemIdList, get the FileTime
2439 *
2440 * PARAMS
2441 * pidl [I] The ItemIDList
2442 * pFt [I] the resulted FILETIME of the file
2443 *
2444 * RETURNS
2445 * True if Successful
2446 *
2447 * NOTES
2448 *
2449 */
2451{
2452 if (_ILGetFSType(pidl) > PT_FS) /* Only non-simple FS items have a date */
2453 {
2455 return DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt);
2456 }
2457 return FALSE;
2458}
2459
2460/*************************************************************************
2461 * _ILGetFileSize
2462 *
2463 * Given the ItemIdList, get the FileSize
2464 *
2465 * PARAMS
2466 * pidl [I] The ItemIDList
2467 * pOut [I] The buffer to save the result
2468 * uOutsize [I] The size of the buffer
2469 *
2470 * RETURNS
2471 * The FileSize
2472 *
2473 * NOTES
2474 * pOut can be null when no string is needed
2475 *
2476 */
2478{
2480 if (!pdata)
2481 return 0;
2482
2483 if (_ILGetFSType(pidl) & PT_FS_FILE_FLAG)
2484 {
2485 /* FIXME: Handle INVALID_FILE_SIZE (get size from disk) */
2486 DWORD dwSize = pdata->u.file.dwFileSize;
2487 if (pOut)
2488 StrFormatKBSizeW(dwSize, pOut, uOutSize);
2489 return dwSize;
2490 }
2491 if (pOut)
2492 *pOut = UNICODE_NULL;
2493 return 0;
2494}
2495
2497{
2498 WCHAR szTemp[MAX_PATH];
2499 LPCWSTR pPoint;
2500 LPCITEMIDLIST pidlTemp = pidl;
2501
2502 TRACE("pidl=%p\n",pidl);
2503
2504 if (!pidl)
2505 return FALSE;
2506
2507 pidlTemp = ILFindLastID(pidl);
2508
2509 if (!_ILIsValue(pidlTemp))
2510 return FALSE;
2511 if (!_ILSimpleGetTextW(pidlTemp, szTemp, _countof(szTemp)))
2512 return FALSE;
2513
2514 pPoint = PathFindExtensionW(szTemp);
2515
2516 if (!*pPoint)
2517 return FALSE;
2518
2519 pPoint++;
2520 lstrcpynW(pOut, pPoint, uOutSize);
2521 TRACE("%s\n", debugstr_w(pOut));
2522
2523 return TRUE;
2524}
2525
2526/*************************************************************************
2527 * _ILGetFileAttributes
2528 *
2529 * Given the ItemIdList, get the Attrib string format
2530 *
2531 * PARAMS
2532 * pidl [I] The ItemIDList
2533 * pOut [I] The buffer to save the result
2534 * uOutsize [I] The size of the Buffer
2535 *
2536 * RETURNS
2537 * Attributes
2538 *
2539 * FIXME
2540 * return value 0 in case of error is a valid return value
2541 *
2542 */
2544{
2545 DWORD wAttrib = 0;
2546 if (_ILGetFSType(pidl))
2547 wAttrib = _ILGetDataPointer(pidl)->u.file.uFileAttribs;
2548
2549 if (uOutSize >= 6)
2550 {
2551 UINT i = 0;
2552 if(wAttrib & FILE_ATTRIBUTE_READONLY)
2553 pOut[i++] = L'R';
2554 if(wAttrib & FILE_ATTRIBUTE_HIDDEN)
2555 pOut[i++] = L'H';
2556 if(wAttrib & FILE_ATTRIBUTE_SYSTEM)
2557 pOut[i++] = L'S';
2558 if(wAttrib & FILE_ATTRIBUTE_ARCHIVE)
2559 pOut[i++] = L'A';
2560 if(wAttrib & FILE_ATTRIBUTE_COMPRESSED)
2561 pOut[i++] = L'C';
2562 pOut[i] = UNICODE_NULL;
2563 }
2564 return wAttrib;
2565}
2566
2567/*************************************************************************
2568 * ILFreeaPidl
2569 *
2570 * frees an aPidl struct
2571 */
2572void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl)
2573{
2574 UINT i;
2575
2576 if (apidl)
2577 {
2578 for (i = 0; i < cidl; i++)
2579 SHFree(apidl[i]);
2580 SHFree(apidl);
2581 }
2582}
2583
2584/*************************************************************************
2585 * ILCopyaPidl
2586 *
2587 * copies an aPidl struct
2588 */
2590{
2591 UINT i;
2592 PITEMID_CHILD *apidldest;
2593
2594 if (!apidlsrc)
2595 return NULL;
2596
2597 apidldest = SHAlloc(cidl * sizeof(PITEMID_CHILD));
2598
2599 for (i = 0; i < cidl; i++)
2600 apidldest[i] = ILClone(apidlsrc[i]);
2601
2602 return apidldest;
2603}
2604
2605/*************************************************************************
2606 * _ILCopyCidaToaPidl
2607 *
2608 * creates aPidl from CIDA
2609 */
2611{
2612 UINT i;
2614
2615 dst = SHAlloc(cida->cidl * sizeof(LPITEMIDLIST));
2616 if (!dst)
2617 return NULL;
2618
2619 if (pidl)
2620 *pidl = ILClone((LPCITEMIDLIST)(&((const BYTE*)cida)[cida->aoffset[0]]));
2621
2622 for (i = 0; i < cida->cidl; i++)
2623 dst[i] = ILClone((LPCITEMIDLIST)(&((const BYTE*)cida)[cida->aoffset[i + 1]]));
2624
2625 return dst;
2626}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int toupper(int c)
Definition: utclib.c:881
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define EXTERN_C
Definition: basetyps.h:12
#define NO_ERROR
Definition: dderror.h:5
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:322
BOOL pcheck(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:360
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SHCIDS_CANONICALONLY
Definition: shobjidl.idl:226
#define GetProcessHeap()
Definition: compat.h:736
#define FIXME_(x)
Definition: compat.h:77
#define CP_ACP
Definition: compat.h:109
#define TRACE_(x)
Definition: compat.h:76
#define lstrcpynA
Definition: compat.h:751
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define wcsicmp
Definition: compat.h:15
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
const GUID CLSID_AdminFolderShortcut
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
DWORD WINAPI SHCLSIDFromStringA(LPCSTR clsid, CLSID *id)
Definition: shellole.c:248
DWORD WINAPI SHCLSIDFromStringW(LPCWSTR clsid, CLSID *id)
Definition: shellole.c:256
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3408
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
LPWSTR WINAPI StrFormatKBSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:1757
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1631
LPWSTR WINAPI StrDupW(LPCWSTR lpszStr)
Definition: string.c:1093
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_CompareIDs
Definition: utils.cpp:15
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
r parent
Definition: btrfs.c:3010
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
FxObject * pParent
Definition: fxdpcapi.cpp:86
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum dst
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT ParseDisplayName([in] HWND hwndOwner, [in] LPBC pbcReserved, [in, string] LPOLESTR lpszDisplayName, [out] ULONG *pchEaten, [out] PIDLIST_RELATIVE *ppidl, [in, out, unique] ULONG *pdwAttributes)
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define PT_FS_UNICODE_FLAG
Definition: lnktool.cpp:41
#define PT_FS
Definition: lnktool.cpp:40
#define PT_COMPUTER_REGITEM
Definition: lnktool.cpp:39
#define PT_DESKTOP_REGITEM
Definition: lnktool.cpp:38
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
const GUID * guid
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static char * dest
Definition: rtl.c:135
static LPOLESTR
Definition: stg_prop.c:27
static PROTOCOLDATA * pdata
Definition: protocol.c:158
static ATOM item
Definition: dde.c:856
REFCLSID clsid
Definition: msctf.c:82
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
interface IBindCtx * LPBC
Definition: objfwd.h:18
const GUID IID_IDataObject
BOOL WINAPI GUIDFromStringW(_In_ PCWSTR psz, _Out_ LPGUID pguid)
#define LOWORD(l)
Definition: pedump.c:82
LPITEMIDLIST WINAPI SHSimpleIDListFromPathA(LPCSTR lpszPath)
Definition: pidl.c:1216
BOOL _ILIsUnicode(LPCITEMIDLIST pidl)
Definition: pidl.c:2037
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:445
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1763
PITEMID_CHILD * _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl)
Definition: pidl.c:2589
static HRESULT _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile, BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
Definition: pidl.c:1149
static LPWSTR _ILGetTextPointerW(LPCITEMIDLIST pidl)
Definition: pidl.c:2247
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1775
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
LPITEMIDLIST WINAPI ILGlobalClone(LPCITEMIDLIST pidl)
Definition: pidl.c:471
static LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2341
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1044
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST *pidl, const CIDA *cida)
Definition: pidl.c:2610
BOOL _ILHACKCompareSimpleIds(LPCITEMIDLIST pidltemp1, LPCITEMIDLIST pidltemp2)
Definition: pidl.c:521
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:403
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2543
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198
HRESULT WINAPI SHGetIDListFromObject(IUnknown *punk, PIDLIST_ABSOLUTE *ppidl)
Definition: pidl.c:1638
LPITEMIDLIST _ILCreateEntireNetwork(void)
Definition: pidl.c:1985
BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:697
LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath)
Definition: pidl.c:1250
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1568
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1506
BOOL _ILIsMyDocuments(LPCITEMIDLIST pidl)
Definition: pidl.c:2051
LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew)
Definition: pidl.c:1965
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:816
LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2300
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1752
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2236
LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl)
Definition: pidl.c:911
HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal)
Definition: pidl.c:860
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:262
LPCITEMIDLIST _ILIsParentEx(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:638
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
Definition: pidl.c:1392
LPITEMIDLIST WINAPI ILCreateFromPathAW(LPCVOID path)
Definition: pidl.c:1115
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:221
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1462
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2408
BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2084
HRESULT _ILCreateFromPathW(LPCWSTR szPath, LPITEMIDLIST *ppidl)
Definition: pidl.c:1946
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:353
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1826
BOOL WINAPI ILGetDisplayName(LPCITEMIDLIST pidl, LPVOID path)
Definition: pidl.c:183
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2102
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uSize)
Definition: pidl.c:2010
LPITEMIDLIST WINAPI ILAppendID(LPITEMIDLIST pidl, LPCSHITEMID item, BOOL bEnd)
Definition: pidl.c:1004
BOOL _ILIsPidlSimple(LPCITEMIDLIST pidl)
Definition: pidl.c:2127
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:2073
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:2062
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1454
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2572
HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1264
void WINAPI ILGlobalFree(LPITEMIDLIST pidl)
Definition: pidl.c:1064
BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type)
Definition: pidl.c:171
HRESULT WINAPI ILLoadFromStream(IStream *pStream, LPITEMIDLIST *ppPidl)
Definition: pidl.c:293
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1238
HRESULT WINAPI SHGetItemFromDataObject(IDataObject *pdtobj, DATAOBJ_GET_ITEM_FLAGS dwFlags, REFIID riid, void **ppv)
Definition: pidl.c:1629
LPVOID WINAPI Alloc(INT)
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:970
LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID)
Definition: pidl.c:1869
EXTERN_C HRESULT BindCtx_RegisterObjectParam(_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
Definition: utils.cpp:574
LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID)
Definition: pidl.c:1881
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:100
static LPITEMIDLIST _ILAlloc(PIDLTYPE type, unsigned int size)
Definition: pidl.c:1726
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2372
LPITEMIDLIST SHELL32_CreateSimpleIDListFromPath(LPCWSTR pszPath, DWORD dwAttributes)
Definition: pidl.c:1188
HRESULT WINAPI SHGetPathCchFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_writes_(cchPathMax) LPWSTR pszPath, _In_ SIZE_T cchPathMax)
Definition: pidl.c:1409
HRESULT WINAPI SHILCreateFromPathAW(LPCVOID path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:419
PUIDLIST_RELATIVE WINAPI ILFindChild(PIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2)
Definition: pidl.c:750
BOOL _ILGetFileDateTime(LPCITEMIDLIST pidl, FILETIME *pFt)
Definition: pidl.c:2450
LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid)
Definition: pidl.c:1844
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1799
HRESULT WINAPI SHILCreateFromPathA(LPCSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:391
DWORD _ILGetFileSize(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2477
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1781
EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx)
Definition: utils.cpp:514
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: pidl.c:2044
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2109
static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
Definition: pidl.c:83
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1101
BOOL _ILIsDrive(LPCITEMIDLIST pidl)
Definition: pidl.c:2095
HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1322
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2496
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1769
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1832
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2156
LPITEMIDLIST WINAPI ILCreateFromPathA(LPCSTR path)
Definition: pidl.c:1085
LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *wfd)
Definition: pidl.c:1898
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:582
LPITEMIDLIST _ILCreateAdminTools(void)
Definition: pidl.c:1838
BOOL _ILIsCPanelStruct(LPCITEMIDLIST pidl)
Definition: pidl.c:2115
#define PT_DRIVE1
Definition: pidl.h:92
#define PT_WORKGRP
Definition: pidl.h:98
#define PT_FOLDER
Definition: pidl.h:94
#define PT_DRIVE3
Definition: pidl.h:90
#define PT_VALUE
Definition: pidl.h:95
BYTE PIDLTYPE
Definition: pidl.h:136
#define PT_DRIVE
Definition: pidl.h:88
struct tagFileStruct FileStruct
#define PT_IESPECIAL1
Definition: pidl.h:102
#define PT_DRIVE2
Definition: pidl.h:89
#define PT_SHARE
Definition: pidl.h:105
#define PT_GUID
Definition: pidl.h:87
static BYTE _ILGetType(LPCITEMIDLIST pidl)
Definition: pidl.h:124
#define PT_COMP
Definition: pidl.h:99
#define PT_NETPROVIDER
Definition: pidl.h:100
static BYTE _ILGetFSType(LPCITEMIDLIST pidl)
Definition: pidl.h:129
#define PT_NETWORK
Definition: pidl.h:101
UINT _ILGetDepth(LPCITEMIDLIST pidl)
static BOOL _ILIsEmpty(LPCITEMIDLIST pidl)
Definition: pidl.h:262
#define PT_CPLAPPLET
Definition: pidl.h:86
#define PT_YAGUID
Definition: pidl.h:103
#define PT_SHELLEXT
Definition: pidl.h:91
#define PT_IESPECIAL2
Definition: pidl.h:104
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define ERR_(ch,...)
Definition: debug.h:156
strcpy
Definition: string.h:131
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len)
Definition: classes.c:422
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:154
#define CSIDL_FLAG_CREATE
#define ILGetSize
Definition: shellclasses.h:638
static SIGDN
Definition: shelldispatch.c:49
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:85
HRESULT hr
Definition: shlfolder.c:183
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static PWSTR *static PWSTR *static DATAOBJ_GET_ITEM_FLAGS
Definition: shlfolder.c:60
#define SHGDFIL_FINDDATA
Definition: shlobj.h:1460
#define SHGDFIL_NETRESOURCE
Definition: shlobj.h:1461
#define SHGDFIL_DESCRIPTIONID
Definition: shlobj.h:1462
#define CSIDL_CONTROLS
Definition: shlobj.h:2184
static const WCHAR CFSTR_SHELLIDLISTW[]
Definition: shlobj.h:514
_In_ int nFolder
Definition: shlobj.h:1527
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:606
SIGDN sigdnName
Definition: shobjidl.idl:606
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_WSTR
Definition: shtypes.idl:85
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const SHITEMID * LPCSHITEMID
Definition: shtypes.idl:30
ITEMIDLIST_RELATIVE UNALIGNED * PUIDLIST_RELATIVE
Definition: shtypes.idl:55
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
Definition: shlobj.h:580
UINT aoffset[1]
Definition: shlobj.h:581
UINT cidl
Definition: shlobj.h:580
WCHAR wszName[1]
Definition: shlfolder.c:1555
WORD cb
Definition: shtypes.idl:27
UINT uType
Definition: shtypes.idl:93
Definition: dsound.c:943
Definition: ffs.h:70
struct tagDriveStruct drive
Definition: pidl.h:214
PIDLTYPE type
Definition: pidl.h:210
struct tagFileStruct file
Definition: pidl.h:215
union tagPIDLDATA::@587 u
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define ILGDN_NORMAL
Definition: undocshell.h:81
#define ILGDN_INFOLDER
Definition: undocshell.h:82
#define ILGDN_FORPARSING
Definition: undocshell.h:80
DWORD dwAttributes
Definition: vdmdbg.h:34
int ret
#define ZeroMemory
Definition: winbase.h:1743
#define CopyMemory
Definition: winbase.h:1741
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
CONST void * LPCVOID
Definition: windef.h:191
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193