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