ReactOS 0.4.16-dev-1338-g8aab5a9
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,
64 _In_opt_ IUnknown *punk,
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 FIXME("(pidl=%p)\n",pidl);
915
916 pdump(pidl);
917
918 return 0;
919}
920
921/*************************************************************************
922 * ILGetSize [SHELL32.152]
923 *
924 * Gets the byte size of an ItemIDList including zero terminator
925 *
926 * PARAMS
927 * pidl [I] ItemIDList
928 *
929 * RETURNS
930 * size of pidl in bytes
931 *
932 * NOTES
933 * exported by ordinal
934 */
936{
937 LPCSHITEMID si;
938 UINT len=0;
939
940 if (pidl)
941 {
942 si = &(pidl->mkid);
943
944 while (si->cb)
945 {
946 len += si->cb;
947 si = (LPCSHITEMID)(((const BYTE*)si)+si->cb);
948 }
949 len += 2;
950 }
951 TRACE("pidl=%p size=%u\n",pidl, len);
952 return len;
953}
954
955/*************************************************************************
956 * ILGetNext [SHELL32.153]
957 *
958 * Gets the next ItemID of an ItemIDList
959 *
960 * PARAMS
961 * pidl [I] ItemIDList
962 *
963 * RETURNS
964 * null -> null
965 * desktop -> null
966 * simple pidl -> pointer to 0x0000 element
967 *
968 * NOTES
969 * exported by ordinal.
970 */
972{
973 WORD len;
974
975 TRACE("%p\n", pidl);
976
977 if (pidl)
978 {
979 len = pidl->mkid.cb;
980 if (len)
981 {
982 pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len);
983 TRACE("-- %p\n", pidl);
984 return (LPITEMIDLIST)pidl;
985 }
986 }
987 return NULL;
988}
989
990/*************************************************************************
991 * ILAppendID [SHELL32.154]
992 *
993 * Adds the single ItemID item to the ItemIDList indicated by pidl.
994 * If bEnd is FALSE, inserts the item in the front of the list,
995 * otherwise it adds the item to the end. (???)
996 *
997 * PARAMS
998 * pidl [I] ItemIDList to extend
999 * item [I] ItemID to prepend/append
1000 * bEnd [I] Indicates if the item should be appended
1001 *
1002 * NOTES
1003 * Destroys the passed in idlist! (???)
1004 */
1006{
1007 LPITEMIDLIST idlRet;
1009
1010 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd);
1011
1012 pdump (pidl);
1013 pdump (itemid);
1014
1015 if (_ILIsDesktop(pidl))
1016 {
1017 idlRet = ILClone(itemid);
1018 SHFree (pidl);
1019 return idlRet;
1020 }
1021
1022 if (bEnd)
1023 idlRet = ILCombine(pidl, itemid);
1024 else
1025 idlRet = ILCombine(itemid, pidl);
1026
1027 SHFree(pidl);
1028 return idlRet;
1029}
1030
1031/*************************************************************************
1032 * ILFree [SHELL32.155]
1033 *
1034 * Frees memory (if not NULL) allocated by SHMalloc allocator
1035 *
1036 * PARAMS
1037 * pidl [I]
1038 *
1039 * RETURNS
1040 * Nothing
1041 *
1042 * NOTES
1043 * exported by ordinal
1044 */
1046{
1047 TRACE("(pidl=%p)\n",pidl);
1048 SHFree(pidl);
1049}
1050
1051/*************************************************************************
1052 * ILGlobalFree [SHELL32.156]
1053 *
1054 * Frees memory (if not NULL) allocated by Alloc allocator
1055 *
1056 * PARAMS
1057 * pidl [I]
1058 *
1059 * RETURNS
1060 * Nothing
1061 *
1062 * NOTES
1063 * exported by ordinal.
1064 */
1066{
1067 TRACE("%p\n", pidl);
1068
1069 Free(pidl);
1070}
1071
1072/*************************************************************************
1073 * ILCreateFromPathA [SHELL32.189]
1074 *
1075 * Creates a complex ItemIDList from a path and returns it.
1076 *
1077 * PARAMS
1078 * path [I]
1079 *
1080 * RETURNS
1081 * the newly created complex ItemIDList or NULL if failed
1082 *
1083 * NOTES
1084 * exported by ordinal.
1085 */
1087{
1088 LPITEMIDLIST pidlnew = NULL;
1089
1090 TRACE_(shell)("%s\n", debugstr_a(path));
1091
1092 if (SUCCEEDED(SHILCreateFromPathA(path, &pidlnew, NULL)))
1093 return pidlnew;
1094 return NULL;
1095}
1096
1097/*************************************************************************
1098 * ILCreateFromPathW [SHELL32.190]
1099 *
1100 * See ILCreateFromPathA.
1101 */
1103{
1104 LPITEMIDLIST pidlnew = NULL;
1105
1106 TRACE_(shell)("%s\n", debugstr_w(path));
1107
1108 if (SUCCEEDED(SHILCreateFromPathW(path, &pidlnew, NULL)))
1109 return pidlnew;
1110 return NULL;
1111}
1112
1113/*************************************************************************
1114 * ILCreateFromPath [SHELL32.157]
1115 */
1117{
1118 if ( SHELL_OsIsUnicode())
1119 return ILCreateFromPathW (path);
1120 return ILCreateFromPathA (path);
1121}
1122
1123/*************************************************************************
1124 * _ILParsePathW [internal]
1125 *
1126 * Creates an ItemIDList from a path and returns it.
1127 *
1128 * PARAMS
1129 * path [I] path to parse and convert into an ItemIDList
1130 * lpFindFile [I] pointer to buffer to initialize the FileSystem
1131 * Bind Data object with
1132 * bBindCtx [I] indicates to create a BindContext and assign a
1133 * FileSystem Bind Data object
1134 * ppidl [O] the newly create ItemIDList
1135 * prgfInOut [I/O] requested attributes on input and actual
1136 * attributes on return
1137 *
1138 * RETURNS
1139 * NO_ERROR on success or an OLE error code
1140 *
1141 * NOTES
1142 * If either lpFindFile is non-NULL or bBindCtx is TRUE, this function
1143 * creates a BindContext object and assigns a FileSystem Bind Data object
1144 * to it, passing the BindContext to IShellFolder_ParseDisplayName. Each
1145 * IShellFolder uses that FileSystem Bind Data object of the BindContext
1146 * to pass data about the current path element to the next object. This
1147 * is used to avoid having to verify the current path element on disk, so
1148 * that creating an ItemIDList from a nonexistent path still can work.
1149 */
1151 BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
1152{
1153 LPSHELLFOLDER pSF = NULL;
1154 LPBC pBC = NULL;
1155 HRESULT ret;
1156
1157 TRACE("%s %p %d (%p)->%p (%p)->0x%x\n", debugstr_w(path), lpFindFile, bBindCtx,
1158 ppidl, ppidl ? *ppidl : NULL,
1159 prgfInOut, prgfInOut ? *prgfInOut : 0);
1160
1161 ret = SHGetDesktopFolder(&pSF);
1162 if (FAILED(ret))
1163 return ret;
1164
1165 if (lpFindFile || bBindCtx)
1166 ret = IFileSystemBindData_Constructor(lpFindFile, &pBC);
1167
1168 if (SUCCEEDED(ret))
1169 {
1170 ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut);
1171 }
1172
1173 if (pBC)
1174 {
1175 IBindCtx_Release(pBC);
1176 pBC = NULL;
1177 }
1178
1179 IShellFolder_Release(pSF);
1180
1181 if (FAILED(ret) && ppidl)
1182 *ppidl = NULL;
1183
1184 TRACE("%s %p 0x%x\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0);
1185
1186 return ret;
1187}
1188
1190{
1192 LPITEMIDLIST pidl = NULL;
1193 _ILParsePathW(pszPath, &data, TRUE, &pidl, NULL);
1194 return pidl;
1195}
1196
1197/*************************************************************************
1198 * SHSimpleIDListFromPath [SHELL32.162]
1199 *
1200 * Creates a simple ItemIDList from a path and returns it. This function
1201 * does not fail on nonexistent paths.
1202 *
1203 * PARAMS
1204 * path [I] path to parse and convert into an ItemIDList
1205 *
1206 * RETURNS
1207 * the newly created simple ItemIDList
1208 *
1209 * NOTES
1210 * Simple in the name does not mean a relative ItemIDList but rather a
1211 * fully qualified list, where only the file name is filled in and the
1212 * directory flag for those ItemID elements this is known about, eg.
1213 * it is not the last element in the ItemIDList or the actual directory
1214 * exists on disk.
1215 * exported by ordinal.
1216 */
1218{
1219 LPITEMIDLIST pidl = NULL;
1220 LPWSTR wPath = NULL;
1221 int len;
1222
1223 TRACE("%s\n", debugstr_a(lpszPath));
1224
1225 if (lpszPath)
1226 {
1227 len = MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, NULL, 0);
1228 wPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1229 MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, wPath, len);
1230 }
1231
1232 _ILParsePathW(wPath, NULL, TRUE, &pidl, NULL);
1233
1234 HeapFree(GetProcessHeap(), 0, wPath);
1235 TRACE("%s %p\n", debugstr_a(lpszPath), pidl);
1236 return pidl;
1237}
1238
1240{
1241 LPITEMIDLIST pidl = NULL;
1242
1243 TRACE("%s\n", debugstr_w(lpszPath));
1244
1245 _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL);
1246
1247 TRACE("%s %p\n", debugstr_w(lpszPath), pidl);
1248 return pidl;
1249}
1250
1252{
1253 if ( SHELL_OsIsUnicode())
1254 return SHSimpleIDListFromPathW (lpszPath);
1255 return SHSimpleIDListFromPathA (lpszPath);
1256}
1257
1259 const SHCOLUMNID *pscid, void*buf, UINT cb)
1260{
1261 VARIANT var;
1262 V_VT(&var) = VT_EMPTY;
1263 HRESULT hr = IShellFolder2_GetDetailsEx(psf2, pidl, pscid, &var);
1264 if (SUCCEEDED(hr))
1265 {
1267 VariantClear(&var);
1268 }
1269 return hr;
1270}
1271
1273 const SHCOLUMNID *pscid, void*buf, UINT cb)
1274{
1275 IShellFolder2 *psf2;
1276 HRESULT hr = IShellFolder_QueryInterface(psf, &IID_IShellFolder2, (void**)&psf2);
1277 if (SUCCEEDED(hr))
1278 {
1279 hr = GetShellFolder2ItemDetailsExToBuffer(psf2, pidl, pscid, buf, cb);
1280 IShellFolder2_Release(psf2);
1281 }
1282 return hr;
1283}
1284
1285/*************************************************************************
1286 * SHGetDataFromIDListA [SHELL32.247]
1287 *
1288 * NOTES
1289 * the pidl can be a simple one. since we can't get the path out of the pidl
1290 * we have to take all data from the pidl
1291 */
1293 int nFormat, LPVOID dest, int len)
1294{
1295 LPSTR filename, shortname;
1297
1298 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
1299
1300 pdump(pidl);
1301 if (!psf || !dest)
1302 return E_INVALIDARG;
1303
1304 switch (nFormat)
1305 {
1306 case SHGDFIL_FINDDATA:
1307 pfd = dest;
1308
1309 if (_ILIsDrive(pidl) || _ILIsSpecialFolder(pidl))
1310 return E_INVALIDARG;
1311
1312 if (len < sizeof(WIN32_FIND_DATAA))
1313 return E_INVALIDARG;
1314
1315 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
1316 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1317 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1318 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1319
1321 shortname = _ILGetSTextPointer(pidl);
1322
1323 if (filename)
1324 lstrcpynA(pfd->cFileName, filename, sizeof(pfd->cFileName));
1325 else
1326 pfd->cFileName[0] = '\0';
1327
1328 if (shortname)
1329 lstrcpynA(pfd->cAlternateFileName, shortname, sizeof(pfd->cAlternateFileName));
1330 else
1331 pfd->cAlternateFileName[0] = '\0';
1332 return S_OK;
1333
1335 return SHGetDataFromIDListW(psf, pidl, nFormat, dest, len);
1336
1338 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1339 break;
1340
1341 default:
1342 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1343 }
1344
1345 return E_INVALIDARG;
1346}
1347
1348/*************************************************************************
1349 * SHGetDataFromIDListW [SHELL32.248]
1350 *
1351 */
1353 int nFormat, LPVOID dest, int len)
1354{
1355 LPSTR filename, shortname;
1357
1358 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
1359
1360 pdump(pidl);
1361
1362 if (!psf || !dest)
1363 return E_INVALIDARG;
1364
1365 switch (nFormat)
1366 {
1367 case SHGDFIL_FINDDATA: /* FIXME: Ask the folder for PID_FINDDATA */
1368 pfd = dest;
1369
1370 if (_ILIsDrive(pidl))
1371 return E_INVALIDARG;
1372
1373 if (len < sizeof(WIN32_FIND_DATAW))
1374 return E_INVALIDARG;
1375
1376 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAW));
1377 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1378 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1379 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1380
1382 shortname = _ILGetSTextPointer(pidl);
1383
1384 if (!filename)
1385 pfd->cFileName[0] = '\0';
1386 else if (!MultiByteToWideChar(CP_ACP, 0, filename, -1, pfd->cFileName, MAX_PATH))
1387 pfd->cFileName[MAX_PATH-1] = 0;
1388
1389 if (!shortname)
1390 pfd->cAlternateFileName[0] = '\0';
1391 else if (!MultiByteToWideChar(CP_ACP, 0, shortname, -1, pfd->cAlternateFileName, 14))
1392 pfd->cAlternateFileName[13] = 0;
1393 return S_OK;
1394
1396 {
1397 /* TODO: Use PKEY_DescriptionID when the propsys headers are ready */
1398 SHCOLUMNID scid = { FMTID_ShellDetails, PID_DESCRIPTIONID };
1399 return GetShellFolder1ItemDetailsExToBuffer(psf, pidl, &scid, dest, len);
1400 }
1401
1403 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1404 break;
1405
1406 default:
1407 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1408 }
1409
1410 return E_INVALIDARG;
1411}
1412
1413/*************************************************************************
1414 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
1415 *
1416 * PARAMETERS
1417 * pidl, [IN] pidl
1418 * pszPath [OUT] path
1419 *
1420 * RETURNS
1421 * path from a passed PIDL.
1422 *
1423 * NOTES
1424 * NULL returns FALSE
1425 * desktop pidl gives path to desktop directory back
1426 * special pidls returning FALSE
1427 */
1429{
1430 WCHAR wszPath[MAX_PATH];
1431 BOOL bSuccess;
1432
1433 bSuccess = SHGetPathFromIDListW(pidl, wszPath);
1434 WideCharToMultiByte(CP_ACP, 0, wszPath, -1, pszPath, MAX_PATH, NULL, NULL);
1435
1436 return bSuccess;
1437}
1438
1439/*************************************************************************
1440 * SHGetPathFromIDListW [SHELL32.@]
1441 *
1442 * See SHGetPathFromIDListA.
1443 */
1446 _In_ LPCITEMIDLIST pidl,
1447 _Out_writes_(cchPathMax) LPWSTR pszPath,
1448 _In_ SIZE_T cchPathMax)
1449{
1450 HRESULT hr;
1451 LPCITEMIDLIST pidlLast;
1452 LPSHELLFOLDER psfFolder;
1454 STRRET strret;
1455
1456 TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
1457 pdump(pidl);
1458
1459 *pszPath = UNICODE_NULL;
1460 if (!pidl)
1461 return E_FAIL;
1462
1463 hr = SHBindToParent(pidl, &IID_IShellFolder, (VOID**)&psfFolder, &pidlLast);
1464 if (FAILED(hr))
1465 {
1466 ERR("SHBindToParent failed: %x\n", hr);
1467 return hr;
1468 }
1469
1470 dwAttributes = SFGAO_FILESYSTEM;
1471 hr = IShellFolder_GetAttributesOf(psfFolder, 1, &pidlLast, &dwAttributes);
1472 if (FAILED(hr) || !(dwAttributes & SFGAO_FILESYSTEM))
1473 {
1474 WARN("Wrong dwAttributes or GetAttributesOf failed: %x\n", hr);
1475 IShellFolder_Release(psfFolder);
1476 return E_FAIL;
1477 }
1478
1479 hr = IShellFolder_GetDisplayNameOf(psfFolder, pidlLast, SHGDN_FORPARSING, &strret);
1480 IShellFolder_Release(psfFolder);
1481 if (FAILED(hr))
1482 return hr;
1483
1484 hr = StrRetToBufW(&strret, pidlLast, pszPath, cchPathMax);
1485
1486 TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(pszPath), hr);
1487 return hr;
1488}
1489
1491{
1492 return SUCCEEDED(SHGetPathCchFromIDListW(pidl, pszPath, MAX_PATH));
1493}
1494
1495/*************************************************************************
1496 * SHBindToParent [shell version 5.0]
1497 */
1499{
1500 IShellFolder * psfDesktop;
1502
1503 TRACE_(shell)("pidl=%p\n", pidl);
1504 pdump(pidl);
1505
1506 if (!pidl || !ppv)
1507 return E_INVALIDARG;
1508
1509 *ppv = NULL;
1510 if (ppidlLast)
1511 *ppidlLast = NULL;
1512
1513 hr = SHGetDesktopFolder(&psfDesktop);
1514 if (FAILED(hr))
1515 return hr;
1516
1517 if (_ILIsPidlSimple(pidl))
1518 {
1519 /* we are on desktop level */
1520 hr = IShellFolder_QueryInterface(psfDesktop, riid, ppv);
1521 }
1522 else
1523 {
1524 LPITEMIDLIST pidlParent = ILClone(pidl);
1525 ILRemoveLastID(pidlParent);
1526 hr = IShellFolder_BindToObject(psfDesktop, pidlParent, NULL, riid, ppv);
1527 SHFree (pidlParent);
1528 }
1529
1530 IShellFolder_Release(psfDesktop);
1531
1532 if (SUCCEEDED(hr) && ppidlLast)
1533 *ppidlLast = ILFindLastID(pidl);
1534
1535 TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08x\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr);
1536 return hr;
1537}
1538
1539/*************************************************************************
1540 * SHParseDisplayName [shell version 6.0]
1541 */
1543 LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
1544{
1545 HRESULT hr;
1546 LPWSTR pszNameDup;
1547 IShellFolder *psfDesktop;
1548 IBindCtx *pBindCtx = NULL;
1549
1550 TRACE("(%s, %p, %p, 0x%X, %p)\n", pszName, pbc, ppidl, sfgaoIn, psfgaoOut);
1551
1552 *ppidl = NULL;
1553
1554 if (psfgaoOut)
1555 *psfgaoOut = 0;
1556
1557 pszNameDup = StrDupW(pszName);
1558 if (!pszNameDup)
1559 return E_OUTOFMEMORY;
1560
1561 psfDesktop = NULL;
1562 hr = SHGetDesktopFolder(&psfDesktop);
1563 if (FAILED(hr))
1564 {
1565 LocalFree(pszNameDup);
1566 return hr;
1567 }
1568
1569 if (!pbc)
1570 {
1571 hr = BindCtx_RegisterObjectParam(NULL, STR_PARSE_TRANSLATE_ALIASES, NULL, &pBindCtx);
1572 pbc = pBindCtx;
1573 }
1574
1575 if (SUCCEEDED(hr))
1576 {
1577 ULONG sfgao = sfgaoIn, cchEaten;
1578 HWND hwndUI = BindCtx_GetUIWindow(pbc);
1579 hr = psfDesktop->lpVtbl->ParseDisplayName(psfDesktop,
1580 hwndUI,
1581 pbc,
1582 pszNameDup,
1583 &cchEaten,
1584 ppidl,
1585 (psfgaoOut ? &sfgao : NULL));
1586 if (SUCCEEDED(hr) && psfgaoOut)
1587 *psfgaoOut = (sfgao & sfgaoIn);
1588 }
1589
1590 LocalFree(pszNameDup);
1591
1592 if (psfDesktop)
1593 psfDesktop->lpVtbl->Release(psfDesktop);
1594
1595 if (pBindCtx)
1596 pBindCtx->lpVtbl->Release(pBindCtx);
1597
1598 return hr;
1599}
1600
1601/*************************************************************************
1602 * SHGetNameFromIDList [SHELL32.@]
1603 */
1605{
1606 IShellFolder *psfparent;
1607 LPCITEMIDLIST child_pidl;
1608 STRRET disp_name;
1609 HRESULT ret;
1610
1611 TRACE("%p 0x%08x %p\n", pidl, sigdnName, ppszName);
1612
1613 *ppszName = NULL;
1614 ret = SHBindToParent(pidl, &IID_IShellFolder, (void**)&psfparent, &child_pidl);
1615 if(SUCCEEDED(ret))
1616 {
1617 switch(sigdnName)
1618 {
1619 /* sigdnName & 0xffff */
1620 case SIGDN_NORMALDISPLAY: /* SHGDN_NORMAL */
1621 case SIGDN_PARENTRELATIVEPARSING: /* SHGDN_INFOLDER | SHGDN_FORPARSING */
1622 case SIGDN_PARENTRELATIVEEDITING: /* SHGDN_INFOLDER | SHGDN_FOREDITING */
1623 case SIGDN_DESKTOPABSOLUTEPARSING: /* SHGDN_FORPARSING */
1624 case SIGDN_DESKTOPABSOLUTEEDITING: /* SHGDN_FOREDITING | SHGDN_FORADDRESSBAR*/
1625 case SIGDN_PARENTRELATIVEFORADDRESSBAR: /* SIGDN_INFOLDER | SHGDN_FORADDRESSBAR */
1626 case SIGDN_PARENTRELATIVE: /* SIGDN_INFOLDER */
1627
1628 disp_name.uType = STRRET_WSTR;
1629 ret = IShellFolder_GetDisplayNameOf(psfparent, child_pidl,
1630 sigdnName & 0xffff,
1631 &disp_name);
1632 if(SUCCEEDED(ret))
1633 ret = StrRetToStrW(&disp_name, pidl, ppszName);
1634
1635 break;
1636
1637 case SIGDN_FILESYSPATH:
1639 if(SHGetPathFromIDListW(pidl, *ppszName))
1640 {
1641 TRACE("Got string %s\n", debugstr_w(*ppszName));
1642 ret = S_OK;
1643 }
1644 else
1645 {
1647 ret = E_INVALIDARG;
1648 }
1649 break;
1650
1651 case SIGDN_URL:
1652 default:
1653 FIXME("Unsupported SIGDN %x\n", sigdnName);
1654 ret = E_FAIL;
1655 }
1656
1657 IShellFolder_Release(psfparent);
1658 }
1659 return ret;
1660}
1661
1662/*************************************************************************
1663 * SHGetItemFromDataObject [SHELL32.@]
1664 */
1666 REFIID riid, void **ppv)
1667{
1668 return E_NOTIMPL; // FIXME
1669}
1670
1671/*************************************************************************
1672 * SHGetIDListFromObject [SHELL32.@]
1673 */
1675{
1676 IPersistIDList *ppersidl;
1677 IPersistFolder2 *ppf2;
1678 IDataObject *pdo;
1679 IFolderView *pfv;
1680 HRESULT ret;
1681
1682 if(!punk)
1683 return E_NOINTERFACE;
1684
1685 *ppidl = NULL;
1686
1687 /* Try IPersistIDList */
1688 ret = IUnknown_QueryInterface(punk, &IID_IPersistIDList, (void**)&ppersidl);
1689 if(SUCCEEDED(ret))
1690 {
1691 TRACE("IPersistIDList (%p)\n", ppersidl);
1692 ret = IPersistIDList_GetIDList(ppersidl, ppidl);
1693 IPersistIDList_Release(ppersidl);
1694 if(SUCCEEDED(ret))
1695 return ret;
1696 }
1697
1698 /* Try IPersistFolder2 */
1699 ret = IUnknown_QueryInterface(punk, &IID_IPersistFolder2, (void**)&ppf2);
1700 if(SUCCEEDED(ret))
1701 {
1702 TRACE("IPersistFolder2 (%p)\n", ppf2);
1703 ret = IPersistFolder2_GetCurFolder(ppf2, ppidl);
1704 IPersistFolder2_Release(ppf2);
1705 if(SUCCEEDED(ret))
1706 return ret;
1707 }
1708
1709 /* Try IDataObject */
1710 ret = IUnknown_QueryInterface(punk, &IID_IDataObject, (void**)&pdo);
1711 if(SUCCEEDED(ret))
1712 {
1713 IShellItem *psi;
1714 TRACE("IDataObject (%p)\n", pdo);
1716 &IID_IShellItem, (void**)&psi);
1717 if(SUCCEEDED(ret))
1718 {
1719 ret = SHGetIDListFromObject((IUnknown*)psi, ppidl);
1720 IShellItem_Release(psi);
1721 }
1722 IDataObject_Release(pdo);
1723
1724 if(SUCCEEDED(ret))
1725 return ret;
1726 }
1727
1728 /* Try IFolderView */
1729 ret = IUnknown_QueryInterface(punk, &IID_IFolderView, (void**)&pfv);
1730 if(SUCCEEDED(ret))
1731 {
1732 IShellFolder *psf;
1733 TRACE("IFolderView (%p)\n", pfv);
1734 ret = IFolderView_GetFolder(pfv, &IID_IShellFolder, (void**)&psf);
1735 if(SUCCEEDED(ret))
1736 {
1737 /* We might be able to get IPersistFolder2 from a shellfolder. */
1738 ret = SHGetIDListFromObject((IUnknown*)psf, ppidl);
1739 }
1740 IFolderView_Release(pfv);
1741 return ret;
1742 }
1743
1744 return ret;
1745}
1746
1747/**************************************************************************
1748 *
1749 * internal functions
1750 *
1751 * ### 1. section creating pidls ###
1752 *
1753 *************************************************************************
1754 */
1755
1756/* Basic PIDL constructor. Allocates size + 5 bytes, where:
1757 * - two bytes are SHITEMID.cb
1758 * - one byte is PIDLDATA.type
1759 * - two bytes are the NULL PIDL terminator
1760 * Sets type of the returned PIDL to type.
1761 */
1763{
1764 LPITEMIDLIST pidlOut = NULL;
1765
1766 pidlOut = SHAlloc(size + 5);
1767 if(pidlOut)
1768 {
1770 LPITEMIDLIST pidlNext;
1771
1772 ZeroMemory(pidlOut, size + 5);
1773 pidlOut->mkid.cb = size + 3;
1774
1775 pData = _ILGetDataPointer(pidlOut);
1776 if (pData)
1777 pData->type = type;
1778
1779 pidlNext = ILGetNext(pidlOut);
1780 if (pidlNext)
1781 pidlNext->mkid.cb = 0x00;
1782 TRACE("-- (pidl=%p, size=%u)\n", pidlOut, size);
1783 }
1784
1785 return pidlOut;
1786}
1787
1789{
1791
1792 TRACE("()\n");
1793 ret = SHAlloc(2);
1794 if (ret)
1795 ret->mkid.cb = 0;
1796 return ret;
1797}
1798
1800{
1801 TRACE("()\n");
1802 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_MyComputer, REGITEMORDER_MYCOMPUTER);
1803}
1804
1806{
1807 TRACE("()\n");
1808 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_MyDocuments, REGITEMORDER_MYDOCS_DEFAULT);
1809}
1810
1812{
1813 TRACE("()\n");
1814 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_Internet, REGITEMORDER_INTERNET);
1815}
1816
1818{
1820
1821 TRACE("()\n");
1822 if (parent)
1823 {
1824 LPITEMIDLIST cpl = _ILCreateGuid(PT_COMPUTER_REGITEM, &CLSID_ControlPanel, REGITEMORDER_MYCOMPUTER_CONTROLS);
1825 if (cpl)
1826 {
1827 ret = ILCombine(parent, cpl);
1828 SHFree(cpl);
1829 }
1830 SHFree(parent);
1831 }
1832 return ret;
1833}
1834
1836{
1837#ifdef __REACTOS__
1838 // Note: Wine returns the PIDL as it was in Windows 95, NT5 moved it into CSIDL_CONTROLS
1839 extern HRESULT SHGetFolderLocationHelper(HWND hwnd, int nFolder, REFCLSID clsid, LPITEMIDLIST *ppidl);
1840 LPITEMIDLIST pidl;
1841 SHGetFolderLocationHelper(NULL, CSIDL_CONTROLS, &CLSID_Printers, &pidl);
1842 return pidl;
1843#else
1844 LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL;
1845
1846 TRACE("()\n");
1847 if (parent)
1848 {
1849 LPITEMIDLIST printers = _ILCreateGuid(PT_YAGUID, &CLSID_Printers);
1850
1851 if (printers)
1852 {
1853 ret = ILCombine(parent, printers);
1854 SHFree(printers);
1855 }
1856 SHFree(parent);
1857 }
1858 return ret;
1859#endif
1860}
1861
1863{
1864 TRACE("()\n");
1865 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_NetworkPlaces, REGITEMORDER_NETHOOD);
1866}
1867
1869{
1870 TRACE("()\n");
1871 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_RecycleBin, REGITEMORDER_RECYCLEBIN);
1872}
1873
1875{
1876 TRACE("()\n");
1877 return _ILCreateGuid(PT_GUID, &CLSID_AdminFolderShortcut, REGITEMORDER_DEFAULT); //FIXME
1878}
1879
1881{
1882 LPITEMIDLIST pidlOut;
1883
1884 if (type == PT_SHELLEXT || type == PT_GUID || type == PT_YAGUID)
1885 {
1886 pidlOut = _ILAlloc(type, sizeof(GUIDStruct));
1887 if (pidlOut)
1888 {
1890 pData->u.guid.uSortOrder = SortOrder;
1891 pData->u.guid.guid = *guid;
1892 TRACE("-- create GUID-pidl %s\n",
1893 debugstr_guid(&(pData->u.guid.guid)));
1894 }
1895 }
1896 else
1897 {
1898 WARN("%d: invalid type for GUID\n", type);
1899 pidlOut = NULL;
1900 }
1901 return pidlOut;
1902}
1903
1904#ifndef __REACTOS__
1906{
1907 IID iid;
1908
1909 if (FAILED(SHCLSIDFromStringA(szGUID, &iid)))
1910 {
1911 ERR("%s is not a GUID\n", szGUID);
1912 return NULL;
1913 }
1914 return _ILCreateGuid(PT_GUID, &iid);
1915}
1916
1918{
1919 IID iid;
1920
1921#ifndef __REACTOS__
1922 if (FAILED(SHCLSIDFromStringW(szGUID, &iid)))
1923#else
1924 if (!GUIDFromStringW(szGUID, &iid))
1925#endif
1926 {
1927 ERR("%s is not a GUID\n", debugstr_w(szGUID));
1928 return NULL;
1929 }
1930 return _ILCreateGuid(PT_GUID, &iid);
1931}
1932#endif /* __REACTOS__ */
1933
1935{
1936 char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */
1937 DWORD len, len1, wlen, alen;
1938 LPITEMIDLIST pidl;
1939 PIDLTYPE type;
1940
1941 if (!wfd)
1942 return NULL;
1943
1944 TRACE("(%s, %s)\n",debugstr_w(wfd->cAlternateFileName), debugstr_w(wfd->cFileName));
1945
1946 /* prepare buffer with both names */
1947 len = WideCharToMultiByte(CP_ACP,0,wfd->cFileName,-1,buff,MAX_PATH,NULL,NULL);
1948 len1 = WideCharToMultiByte(CP_ACP,0,wfd->cAlternateFileName,-1, buff+len, sizeof(buff)-len, NULL, NULL);
1949 alen = len + len1;
1950
1951 type = (wfd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? PT_FOLDER : PT_VALUE;
1952
1953 wlen = lstrlenW(wfd->cFileName) + 1;
1954 pidl = _ILAlloc(type, FIELD_OFFSET(FileStruct, szNames[alen + (alen & 1)]) +
1955 FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD));
1956 if (pidl)
1957 {
1959 FileStruct *fs = &pData->u.file;
1960 FileStructW *fsw;
1961 WORD *pOffsetW;
1962
1963 FileTimeToDosDateTime( &wfd->ftLastWriteTime, &fs->uFileDate, &fs->uFileTime);
1964 fs->dwFileSize = wfd->nFileSizeLow;
1965 fs->uFileAttribs = wfd->dwFileAttributes;
1966 memcpy(fs->szNames, buff, alen);
1967
1968 fsw = (FileStructW*)(pData->u.file.szNames + alen + (alen & 0x1));
1969 fsw->cbLen = FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD);
1970 FileTimeToDosDateTime( &wfd->ftCreationTime, &fsw->uCreationDate, &fsw->uCreationTime);
1971 FileTimeToDosDateTime( &wfd->ftLastAccessTime, &fsw->uLastAccessDate, &fsw->uLastAccessTime);
1972 memcpy(fsw->wszName, wfd->cFileName, wlen * sizeof(WCHAR));
1973
1974 pOffsetW = (WORD*)((LPBYTE)pidl + pidl->mkid.cb - sizeof(WORD));
1975 *pOffsetW = (LPBYTE)fsw - (LPBYTE)pidl;
1976 TRACE("-- Set Value: %s\n",debugstr_w(fsw->wszName));
1977 }
1978 return pidl;
1979
1980}
1981
1983{
1984 HANDLE hFile;
1985 WIN32_FIND_DATAW stffile;
1986
1987 if (!ppidl)
1988 return E_INVALIDARG;
1989
1990 hFile = FindFirstFileW(szPath, &stffile);
1993
1995
1996 *ppidl = _ILCreateFromFindDataW(&stffile);
1997
1998 return *ppidl ? S_OK : E_OUTOFMEMORY;
1999}
2000
2002{
2003 LPITEMIDLIST pidlOut;
2004
2005 TRACE("(%s)\n",debugstr_w(lpszNew));
2006
2007 pidlOut = _ILAlloc(PT_DRIVE, sizeof(DriveStruct));
2008 if (pidlOut)
2009 {
2010 LPSTR pszDest = _ILGetTextPointer(pidlOut);
2011 if (pszDest)
2012 {
2013 lstrcpyA(pszDest, "x:\\");
2014 pszDest[0] = toupper(lpszNew[0]);
2015 TRACE("-- create Drive: %s\n", debugstr_a(pszDest));
2016 }
2017 }
2018 return pidlOut;
2019}
2020
2022{
2023 LPITEMIDLIST pidlOut;
2024
2025 TRACE("\n");
2026
2027 pidlOut = _ILAlloc(PT_NETWORK, FIELD_OFFSET(PIDLDATA, u.network.szNames[sizeof("Entire Network")]));
2028 if (pidlOut)
2029 {
2031
2032 pData->u.network.dummy = 0;
2033 strcpy(pData->u.network.szNames, "Entire Network");
2034 }
2035 return pidlOut;
2036}
2037
2038/**************************************************************************
2039 * _ILGetDrive()
2040 *
2041 * Gets the text for the drive eg. 'c:\'
2042 *
2043 * RETURNS
2044 * strlen (lpszText)
2045 */
2047{
2048 TRACE("(%p,%p,%u)\n",pidl,pOut,uSize);
2049
2050 if(_ILIsMyComputer(pidl))
2051 pidl = ILGetNext(pidl);
2052
2053 if (pidl && _ILIsDrive(pidl))
2054 return _ILSimpleGetTextW(pidl, pOut, uSize);
2055
2056 return 0;
2057}
2058
2059/**************************************************************************
2060 *
2061 * ### 2. section testing pidls ###
2062 *
2063 **************************************************************************
2064 * _ILIsUnicode()
2065 * _ILIsDesktop()
2066 * _ILIsMyComputer()
2067 * _ILIsSpecialFolder()
2068 * _ILIsDrive()
2069 * _ILIsFolder()
2070 * _ILIsValue()
2071 * _ILIsPidlSimple()
2072 */
2074{
2075 TRACE("(%p)\n",pidl);
2076
2077 return (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG) != 0;
2078}
2079
2081{
2082 TRACE("(%p)\n",pidl);
2083
2084 return !pidl || !pidl->mkid.cb;
2085}
2086
2088{
2089 IID *iid = _ILGetGUIDPointer(pidl);
2090
2091 TRACE("(%p)\n", pidl);
2092
2093 if (iid)
2094 return IsEqualIID(iid, &CLSID_MyDocuments);
2095 return FALSE;
2096}
2097
2099{
2100 REFIID iid = _ILGetGUIDPointer(pidl);
2101
2102 TRACE("(%p)\n",pidl);
2103
2104 if (iid)
2105 return IsEqualIID(iid, &CLSID_MyComputer);
2106 return FALSE;
2107}
2108
2110{
2111 IID *iid = _ILGetGUIDPointer(pidl);
2112
2113 TRACE("(%p)\n", pidl);
2114
2115 if (iid)
2116 return IsEqualIID(iid, &CLSID_RecycleBin);
2117 return FALSE;
2118}
2119
2121{
2122 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
2123
2124 TRACE("(%p)\n",pidl);
2125
2126 return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type || PT_YAGUID == lpPData->type)) ||
2127 (pidl && pidl->mkid.cb == 0x00)
2128 ));
2129}
2130
2132{
2133 const BYTE type = _ILGetType(pidl);
2134 const BYTE fldrtype = (PT_DRIVE & PT_FOLDERTYPEMASK);
2135 return (type & PT_FOLDERTYPEMASK) == fldrtype && type != PT_COMPUTER_REGITEM;
2136}
2137
2139{
2140 /* A folder or a simple PT_FS with a child */
2141 const BYTE type = _ILGetFSType(pidl);
2142 return (type & PT_FS_FOLDER_FLAG) != 0 || (type == PT_FS && ILGetNext(pidl));
2143}
2144
2146{
2147 const BYTE type = _ILGetFSType(pidl);
2148 return type && !(type & PT_FS_FOLDER_FLAG);
2149}
2150
2152{
2153 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
2154
2155 TRACE("(%p)\n",pidl);
2156
2157 return (pidl && lpPData && (lpPData->type == 0));
2158}
2159
2160/**************************************************************************
2161 * _ILIsPidlSimple
2162 */
2164{
2165 BOOL ret = TRUE;
2166
2167 if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */
2168 {
2169 WORD len = pidl->mkid.cb;
2170 LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len );
2171
2172 if (pidlnext->mkid.cb)
2173 ret = FALSE;
2174 }
2175
2176 TRACE("%s\n", ret ? "Yes" : "No");
2177 return ret;
2178}
2179
2180/**************************************************************************
2181 *
2182 * ### 3. section getting values from pidls ###
2183 */
2184
2185/**************************************************************************
2186 * _ILSimpleGetTextW
2187 *
2188 * gets the text for the first item in the pidl (eg. simple pidl)
2189 *
2190 * returns the length of the string
2191 */
2193{
2194 DWORD dwReturn;
2195 FileStructW *pFileStructW = _ILGetFileStructW(pidl);
2196
2197 TRACE("(%p %p %x)\n",pidl,szOut,uOutSize);
2198
2199 if (pFileStructW) {
2200 lstrcpynW(szOut, pFileStructW->wszName, uOutSize);
2201 dwReturn = lstrlenW(pFileStructW->wszName);
2202 } else {
2203 GUID const * riid;
2204 WCHAR szTemp[MAX_PATH];
2205 LPSTR szSrc;
2206 LPWSTR szSrcW;
2207 dwReturn=0;
2208
2209 if (!pidl)
2210 return 0;
2211
2212 if (szOut)
2213 *szOut = 0;
2214
2215 if (_ILIsDesktop(pidl))
2216 {
2217 /* desktop */
2218 if (HCR_GetClassNameW(&CLSID_ShellDesktop, szTemp, _countof(szTemp)))
2219 {
2220 if (szOut)
2221 lstrcpynW(szOut, szTemp, uOutSize);
2222
2223 dwReturn = lstrlenW (szTemp);
2224 }
2225 }
2226 else if (( szSrcW = _ILGetTextPointerW(pidl) ))
2227 {
2228 /* unicode filesystem */
2229 if (szOut)
2230 lstrcpynW(szOut, szSrcW, uOutSize);
2231
2232 dwReturn = lstrlenW(szSrcW);
2233 }
2234 else if (( szSrc = _ILGetTextPointer(pidl) ))
2235 {
2236 /* filesystem */
2237 MultiByteToWideChar(CP_ACP, 0, szSrc, -1, szTemp, _countof(szTemp));
2238
2239 if (szOut)
2240 lstrcpynW(szOut, szTemp, uOutSize);
2241
2242 dwReturn = lstrlenW (szTemp);
2243 }
2244 else if (( riid = _ILGetGUIDPointer(pidl) ))
2245 {
2246 /* special folder */
2247 if ( HCR_GetClassNameW(riid, szTemp, _countof(szTemp)))
2248 {
2249 if (szOut)
2250 lstrcpynW(szOut, szTemp, uOutSize);
2251
2252 dwReturn = lstrlenW (szTemp);
2253 }
2254 }
2255 else
2256 {
2257 ERR("-- no text\n");
2258 }
2259 }
2260
2261 TRACE("-- (%p=%s 0x%08x)\n",szOut,debugstr_w(szOut),dwReturn);
2262 return dwReturn;
2263}
2264
2265/**************************************************************************
2266 *
2267 * ### 4. getting pointers to parts of pidls ###
2268 *
2269 **************************************************************************
2270 * _ILGetDataPointer()
2271 */
2273{
2274 if(!_ILIsEmpty(pidl))
2275 return (LPPIDLDATA)pidl->mkid.abID;
2276 return NULL;
2277}
2278
2279/**************************************************************************
2280 * _ILGetTextPointerW()
2281 * gets a pointer to the unicode long filename string stored in the pidl
2282 */
2284{
2285 /* TRACE(pidl,"(pidl%p)\n", pidl);*/
2286
2288
2289 if (!pdata)
2290 return NULL;
2291
2292 if (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG)
2293 return (LPWSTR)pdata->u.file.szNames;
2294
2295 switch (pdata->type)
2296 {
2297 case PT_GUID:
2298 case PT_SHELLEXT:
2299 case PT_YAGUID:
2300 return NULL;
2301
2302 case PT_DRIVE:
2303 case PT_DRIVE1:
2304 case PT_DRIVE2:
2305 case PT_DRIVE3:
2306 /*return (LPSTR)&(pdata->u.drive.szDriveName);*/
2307 return NULL;
2308
2309 case PT_IESPECIAL1:
2310 case PT_IESPECIAL2:
2311 /*return (LPSTR)&(pdata->u.file.szNames);*/
2312 return NULL;
2313
2314 case PT_WORKGRP:
2315 case PT_COMP:
2316 case PT_NETWORK:
2317 case PT_NETPROVIDER:
2318 case PT_SHARE:
2319 /*return (LPSTR)&(pdata->u.network.szNames);*/
2320 return NULL;
2321
2322#ifdef __REACTOS__ /* r54423 */
2323 case PT_CPLAPPLET:
2324 return pdata->u.cpanel.szName;
2325#endif
2326
2327 }
2328 return NULL;
2329}
2330
2331
2332/**************************************************************************
2333 * _ILGetTextPointer()
2334 * gets a pointer to the long filename string stored in the pidl
2335 */
2337{
2338 /* TRACE(pidl,"(pidl%p)\n", pidl);*/
2339
2340 PIDLTYPE type;
2342 if (!pdata)
2343 return NULL;
2344
2345 type = _ILGetFSType(pidl);
2346 if (type && !(type & PT_FS_UNICODE_FLAG))
2347 return pdata->u.file.szNames;
2348
2349 if (_ILIsDrive(pidl))
2350 return pdata->u.drive.szDriveName;
2351
2352 switch (pdata->type)
2353 {
2354 case PT_GUID:
2355 case PT_SHELLEXT:
2356 case PT_YAGUID:
2357 return NULL;
2358
2359 case PT_IESPECIAL1:
2360 case PT_IESPECIAL2:
2361 return pdata->u.file.szNames;
2362
2363 case PT_WORKGRP:
2364 case PT_COMP:
2365 case PT_NETWORK:
2366 case PT_NETPROVIDER:
2367 case PT_SHARE:
2368 return pdata->u.network.szNames;
2369 }
2370 return NULL;
2371}
2372
2373/**************************************************************************
2374 * _ILGetSTextPointer()
2375 * gets a pointer to the short filename string stored in the pidl
2376 */
2378{
2379 /* TRACE(pidl,"(pidl%p)\n", pidl); */
2380
2381 PIDLTYPE type;
2383 if (!pdata)
2384 return NULL;
2385
2386 type = pdata->type;
2387 if (_ILGetFSType(pidl) && !(type & PT_FS_UNICODE_FLAG))
2388 type = PT_FS;
2389
2390 switch (type)
2391 {
2392 case PT_FS:
2393 case PT_IESPECIAL1:
2394 case PT_IESPECIAL2:
2395 return pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1;
2396
2397 case PT_WORKGRP:
2398 return pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1;
2399 }
2400 return NULL;
2401}
2402
2403/**************************************************************************
2404 * _ILGetGUIDPointer()
2405 *
2406 * returns reference to guid stored in some pidls
2407 */
2409{
2411
2412 TRACE("%p\n", pidl);
2413
2414 if (!pdata)
2415 return NULL;
2416
2417 TRACE("pdata->type 0x%04x\n", pdata->type);
2418 switch (pdata->type)
2419 {
2420 case PT_SHELLEXT:
2421 case PT_GUID:
2422 case PT_YAGUID:
2423 return &(pdata->u.guid.guid);
2424
2425 default:
2426 TRACE("Unknown pidl type 0x%04x\n", pdata->type);
2427 break;
2428 }
2429 return NULL;
2430}
2431
2432/******************************************************************************
2433 * _ILGetFileStructW [Internal]
2434 *
2435 * Get pointer the a SHITEMID's FileStructW field if present
2436 *
2437 * PARAMS
2438 * pidl [I] The SHITEMID
2439 *
2440 * RETURNS
2441 * Success: Pointer to pidl's FileStructW field.
2442 * Failure: NULL
2443 */
2445 FileStructW *pFileStructW;
2446 WORD cbOffset;
2447
2448 if (!_ILIsFolderOrFile(pidl))
2449 return NULL;
2450
2451 cbOffset = *(const WORD *)((const BYTE *)pidl + pidl->mkid.cb - sizeof(WORD));
2452 pFileStructW = (FileStructW*)((LPBYTE)pidl + cbOffset);
2453
2454 /* Currently I don't see a fool prove way to figure out if a pidl is for sure of WinXP
2455 * style with a FileStructW member. If we switch all our shellfolder-implementations to
2456 * the new format, this won't be a problem. For now, we do as many sanity checks as possible. */
2457 if ((cbOffset & 0x1) || /* FileStructW member is word aligned in the pidl */
2458 /* FileStructW is positioned after FileStruct */
2459 cbOffset < sizeof(pidl->mkid.cb) + sizeof(PIDLTYPE) + sizeof(FileStruct) ||
2460 /* There has to be enough space at cbOffset in the pidl to hold FileStructW and cbOffset */
2461 cbOffset > pidl->mkid.cb - sizeof(cbOffset) - sizeof(FileStructW) ||
2462 pidl->mkid.cb != cbOffset + pFileStructW->cbLen)
2463 {
2464 WARN("Invalid pidl format (cbOffset = %d)!\n", cbOffset);
2465 return NULL;
2466 }
2467
2468 return pFileStructW;
2469}
2470
2471/*************************************************************************
2472 * _ILGetFileDateTime
2473 *
2474 * Given the ItemIdList, get the FileTime
2475 *
2476 * PARAMS
2477 * pidl [I] The ItemIDList
2478 * pFt [I] the resulted FILETIME of the file
2479 *
2480 * RETURNS
2481 * True if Successful
2482 *
2483 * NOTES
2484 *
2485 */
2487{
2488 if (_ILGetFSType(pidl) > PT_FS) /* Only non-simple FS items have a date */
2489 {
2491 return DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt);
2492 }
2493 return FALSE;
2494}
2495
2496/*************************************************************************
2497 * _ILGetFileSize
2498 *
2499 * Given the ItemIdList, get the FileSize
2500 *
2501 * PARAMS
2502 * pidl [I] The ItemIDList
2503 * pOut [I] The buffer to save the result
2504 * uOutsize [I] The size of the buffer
2505 *
2506 * RETURNS
2507 * The FileSize
2508 *
2509 * NOTES
2510 * pOut can be null when no string is needed
2511 *
2512 */
2514{
2516 if (!pdata)
2517 return 0;
2518
2519 if (_ILGetFSType(pidl) & PT_FS_FILE_FLAG)
2520 {
2521 /* FIXME: Handle INVALID_FILE_SIZE (get size from disk) */
2522 DWORD dwSize = pdata->u.file.dwFileSize;
2523 if (pOut)
2524 StrFormatKBSizeW(dwSize, pOut, uOutSize);
2525 return dwSize;
2526 }
2527 if (pOut)
2528 *pOut = UNICODE_NULL;
2529 return 0;
2530}
2531
2533{
2534 WCHAR szTemp[MAX_PATH];
2535 LPCWSTR pPoint;
2536 LPCITEMIDLIST pidlTemp = pidl;
2537
2538 TRACE("pidl=%p\n",pidl);
2539
2540 if (!pidl)
2541 return FALSE;
2542
2543 pidlTemp = ILFindLastID(pidl);
2544
2545 if (!_ILIsValue(pidlTemp))
2546 return FALSE;
2547 if (!_ILSimpleGetTextW(pidlTemp, szTemp, _countof(szTemp)))
2548 return FALSE;
2549
2550 pPoint = PathFindExtensionW(szTemp);
2551
2552 if (!*pPoint)
2553 return FALSE;
2554
2555 pPoint++;
2556 lstrcpynW(pOut, pPoint, uOutSize);
2557 TRACE("%s\n", debugstr_w(pOut));
2558
2559 return TRUE;
2560}
2561
2562/*************************************************************************
2563 * _ILGetFileAttributes
2564 *
2565 * Given the ItemIdList, get the Attrib string format
2566 *
2567 * PARAMS
2568 * pidl [I] The ItemIDList
2569 * pOut [I] The buffer to save the result
2570 * uOutsize [I] The size of the Buffer
2571 *
2572 * RETURNS
2573 * Attributes
2574 *
2575 * FIXME
2576 * return value 0 in case of error is a valid return value
2577 *
2578 */
2580{
2581 DWORD wAttrib = 0;
2582 if (_ILGetFSType(pidl))
2583 wAttrib = _ILGetDataPointer(pidl)->u.file.uFileAttribs;
2584
2585 if (uOutSize >= 6)
2586 {
2587 UINT i = 0;
2588 if(wAttrib & FILE_ATTRIBUTE_READONLY)
2589 pOut[i++] = L'R';
2590 if(wAttrib & FILE_ATTRIBUTE_HIDDEN)
2591 pOut[i++] = L'H';
2592 if(wAttrib & FILE_ATTRIBUTE_SYSTEM)
2593 pOut[i++] = L'S';
2594 if(wAttrib & FILE_ATTRIBUTE_ARCHIVE)
2595 pOut[i++] = L'A';
2596 if(wAttrib & FILE_ATTRIBUTE_COMPRESSED)
2597 pOut[i++] = L'C';
2598 pOut[i] = UNICODE_NULL;
2599 }
2600 return wAttrib;
2601}
2602
2603/*************************************************************************
2604 * ILFreeaPidl
2605 *
2606 * frees an aPidl struct
2607 */
2608void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl)
2609{
2610 if (apidl)
2611 {
2612 for (UINT i = 0; i < cidl; i++)
2613 SHFree(apidl[i]);
2614 SHFree(apidl);
2615 }
2616}
2617
2618/*************************************************************************
2619 * ILCopyaPidl
2620 *
2621 * copies an aPidl struct
2622 */
2624{
2625 PITEMID_CHILD *apidldest;
2626
2627 if (!apidlsrc)
2628 return NULL;
2629
2630 apidldest = SHAlloc(cidl * sizeof(PITEMID_CHILD));
2631 for (UINT i = 0; i < cidl; i++)
2632 {
2633 PITEMID_CHILD clone = ILClone(apidlsrc[i]);
2634 if ((apidldest[i] = clone) == NULL)
2635 {
2636 _ILFreeaPidl(apidldest, i);
2637 return NULL;
2638 }
2639 }
2640 return apidldest;
2641}
2642
2643/*************************************************************************
2644 * _ILCopyCidaToaPidl
2645 *
2646 * creates aPidl from CIDA
2647 */
2649{
2650 UINT i;
2651 LPITEMIDLIST *dst = SHAlloc(cida->cidl * sizeof(LPITEMIDLIST));
2652 if (!dst)
2653 return NULL;
2654
2655 for (i = 0; i < cida->cidl; i++)
2656 {
2657 PITEMID_CHILD clone = ILClone(HIDA_GetPIDLItem(cida, i));
2658 if ((dst[i] = clone) == NULL)
2659 {
2660 _ILFreeaPidl(dst, i);
2661 return NULL;
2662 }
2663 }
2664
2665 if (pidl)
2666 {
2667 *pidl = ILClone(HIDA_GetPIDLFolder(cida));
2668 if (!*pidl)
2669 {
2670 _ILFreeaPidl(dst, cida->cidl);
2671 return NULL;
2672 }
2673 }
2674 return dst;
2675}
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
@ 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:1217
WCHAR *WINAPI StrDupW(const WCHAR *str)
Definition: string.c:313
GUID guid
Definition: version.c:147
const GUID CLSID_AdminFolderShortcut
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:337
DWORD WINAPI SHCLSIDFromStringA(LPCSTR clsid, CLSID *id)
Definition: shellole.c:259
DWORD WINAPI SHCLSIDFromStringW(LPCWSTR clsid, CLSID *id)
Definition: shellole.c:267
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:315
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: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
#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 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 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
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
#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:33
static char * dest
Definition: rtl.c:135
static LPOLESTR
Definition: stg_prop.c:27
static PROTOCOLDATA * pdata
Definition: protocol.c:158
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
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:1217
BOOL _ILIsUnicode(LPCITEMIDLIST pidl)
Definition: pidl.c:2073
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:446
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1799
PITEMID_CHILD * _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl)
Definition: pidl.c:2623
static HRESULT _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile, BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
Definition: pidl.c:1150
static LPWSTR _ILGetTextPointerW(LPCITEMIDLIST pidl)
Definition: pidl.c:2283
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1811
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:2377
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1045
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST *pidl, const CIDA *cida)
Definition: pidl.c:2648
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:2579
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199
HRESULT WINAPI SHGetIDListFromObject(IUnknown *punk, PIDLIST_ABSOLUTE *ppidl)
Definition: pidl.c:1674
LPITEMIDLIST _ILCreateEntireNetwork(void)
Definition: pidl.c:2021
BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:698
LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath)
Definition: pidl.c:1251
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1604
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1542
BOOL _ILIsMyDocuments(LPCITEMIDLIST pidl)
Definition: pidl.c:2087
LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew)
Definition: pidl.c:2001
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2336
static HRESULT GetShellFolder2ItemDetailsExToBuffer(IShellFolder2 *psf2, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, void *buf, UINT cb)
Definition: pidl.c:1258
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1788
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2272
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:1428
LPITEMIDLIST WINAPI ILCreateFromPathAW(LPCVOID path)
Definition: pidl.c:1116
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:222
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1498
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2444
BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2120
HRESULT _ILCreateFromPathW(LPCWSTR szPath, LPITEMIDLIST *ppidl)
Definition: pidl.c:1982
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:354
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1862
BOOL WINAPI ILGetDisplayName(LPCITEMIDLIST pidl, LPVOID path)
Definition: pidl.c:184
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2138
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uSize)
Definition: pidl.c:2046
LPITEMIDLIST WINAPI ILAppendID(LPITEMIDLIST pidl, LPCSHITEMID item, BOOL bEnd)
Definition: pidl.c:1005
BOOL _ILIsPidlSimple(LPCITEMIDLIST pidl)
Definition: pidl.c:2163
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:2109
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:2098
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1490
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2608
HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1292
void WINAPI ILGlobalFree(LPITEMIDLIST pidl)
Definition: pidl.c:1065
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:1239
HRESULT WINAPI SHGetItemFromDataObject(IDataObject *pdtobj, DATAOBJ_GET_ITEM_FLAGS dwFlags, REFIID riid, void **ppv)
Definition: pidl.c:1665
LPVOID WINAPI Alloc(INT)
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:971
LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID)
Definition: pidl.c:1905
EXTERN_C HRESULT BindCtx_RegisterObjectParam(_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
Definition: utils.cpp:597
LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID)
Definition: pidl.c:1917
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:1762
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2408
LPITEMIDLIST SHELL32_CreateSimpleIDListFromPath(LPCWSTR pszPath, DWORD dwAttributes)
Definition: pidl.c:1189
HRESULT WINAPI SHGetPathCchFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_writes_(cchPathMax) LPWSTR pszPath, _In_ SIZE_T cchPathMax)
Definition: pidl.c:1445
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:2486
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1835
HRESULT WINAPI SHILCreateFromPathA(LPCSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
DWORD _ILGetFileSize(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2513
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1817
static HRESULT GetShellFolder1ItemDetailsExToBuffer(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, void *buf, UINT cb)
Definition: pidl.c:1272
EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx)
Definition: utils.cpp:537
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: pidl.c:2080
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2145
static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
Definition: pidl.c:84
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1102
BOOL _ILIsDrive(LPCITEMIDLIST pidl)
Definition: pidl.c:2131
HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1352
LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid, BYTE SortOrder)
Definition: pidl.c:1880
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2532
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1805
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1868
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2192
LPITEMIDLIST WINAPI ILCreateFromPathA(LPCSTR path)
Definition: pidl.c:1086
LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *wfd)
Definition: pidl.c:1934
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:583
LPITEMIDLIST _ILCreateAdminTools(void)
Definition: pidl.c:1874
BOOL _ILIsCPanelStruct(LPCITEMIDLIST pidl)
Definition: pidl.c:2151
#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
#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:270
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:164
#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:695
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:690
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: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:234
PIDLTYPE type
Definition: pidl.h:230
struct tagFileStruct file
Definition: pidl.h:235
union tagPIDLDATA::@624 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:75
#define ILGDN_INFOLDER
Definition: undocshell.h:76
#define ILGDN_FORPARSING
Definition: undocshell.h:74
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:648
DWORD dwAttributes
Definition: vdmdbg.h:34
#define ZeroMemory
Definition: winbase.h:1753
#define CopyMemory
Definition: winbase.h:1751
_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