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