ReactOS 0.4.15-dev-8428-g6910fa6
CRegFolder.cpp
Go to the documentation of this file.
1/*
2 * ReactOS Shell
3 *
4 * Copyright 2016 Giannis Adamopoulos
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <precomp.h>
22
24
26 HWND hwnd,
27 IDataObject *pdtobj,
28 UINT uMsg,
31{
33 return SHELL32_DefaultContextMenuCallBack(psf, pdtobj, uMsg);
34
35 PIDLIST_ABSOLUTE pidlFolder;
36 PUITEMID_CHILD *apidl;
37 UINT cidl;
38 HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
40 return hr;
41
42 if (_ILIsMyComputer(apidl[0]))
43 {
44 if (!SHELL_ExecuteControlPanelCPL(hwnd, L"sysdm.cpl"))
45 {
46 hr = E_FAIL;
47 }
48 }
49 else if (_ILIsDesktop(apidl[0]))
50 {
51 if (!SHELL_ExecuteControlPanelCPL(hwnd, L"desk.cpl"))
52 {
53 hr = E_FAIL;
54 }
55 }
56 else if (_ILIsNetHood(apidl[0]))
57 {
58 // FIXME path!
59 if (32 >= (UINT_PTR)ShellExecuteW(NULL,
60 L"open",
61 L"explorer.exe",
62 L"::{7007ACC7-3202-11D1-AAD2-00805FC1270E}",
63 NULL,
65 {
66 hr = E_FAIL;
67 }
68 }
69 else if (_ILIsBitBucket(apidl[0]))
70 {
71 /* FIXME: detect the drive path of bitbucket if appropiate */
73 hr = E_FAIL;
74 }
75 else
76 {
77 /* Tell the caller to run the default action */
78 hr = S_FALSE;
79 }
80
81 SHFree(pidlFolder);
82 _ILFreeaPidl(apidl, cidl);
83
84 return hr;
85}
86
88 HWND hwnd,
89 UINT cidl,
91 IShellFolder *psf,
92 IContextMenu **ppcm)
93{
94 HKEY hKeys[10];
95 UINT cKeys = 0;
96
97 GUID *pGuid = _ILGetGUIDPointer(apidl[0]);
98 if (pGuid)
99 {
100 WCHAR key[60];
101 wcscpy(key, L"CLSID\\");
102 StringFromGUID2(*pGuid, &key[6], 39);
103 AddClassKeyToArray(key, hKeys, &cKeys);
104 }
105
106 // FIXME: CRegFolder should be aggregated by its outer folder and should
107 // provide the attributes for all required non-registry folders.
108 // It currently does not so we have to ask the outer folder ourself so
109 // that we get the correct attributes for My Computer etc.
110 CComPtr<IShellFolder> pOuterSF;
111 SHBindToObject(NULL, pidlFolder, IID_PPV_ARG(IShellFolder, &pOuterSF));
112
113 SFGAOF att = (psf && cidl) ? SHGetAttributes(pOuterSF ? pOuterSF.p : psf, apidl[0], SFGAO_FOLDER) : 0;
114 if (att & SFGAO_FOLDER)
115 AddClassKeyToArray(L"Folder", hKeys, &cKeys);
116
117 return CDefFolderMenu_Create2(pidlFolder, hwnd, cidl, apidl, psf, RegFolderContextMenuCallback, cKeys, hKeys, ppcm);
118}
119
121{
122 WCHAR xriid[40];
123
124 if (!StringFromGUID2(*riid, xriid, _countof(xriid) - 1))
125 return E_FAIL;
126
127 return StringCchPrintfW(KeyName, KeySize, RegPath, xriid);
128}
129
131{
132 CComPtr<IDefaultExtractIconInit> initIcon;
133 HRESULT hr;
134 GUID const * riid;
135 int icon_idx;
136 WCHAR wTemp[MAX_PATH];
137
139 if (FAILED(hr))
140 return hr;
141
142 if (_ILIsDesktop(pidl))
143 {
144 initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DESKTOP);
145 return initIcon->QueryInterface(iid, ppvOut);
146 }
147
148 riid = _ILGetGUIDPointer(pidl);
149 if (!riid)
150 return E_FAIL;
151
152 /* Choose a correct icon for Recycle Bin (full or empty) */
153 const WCHAR* iconname = NULL;
154 if (_ILIsBitBucket(pidl))
155 {
156 CComPtr<IEnumIDList> EnumIDList;
158
159 CComPtr<IShellFolder2> psfRecycleBin;
160 CComPtr<IShellFolder> psfDesktop;
161 hr = SHGetDesktopFolder(&psfDesktop);
162
163 if (SUCCEEDED(hr))
164 hr = psfDesktop->BindToObject(pidl, NULL, IID_PPV_ARG(IShellFolder2, &psfRecycleBin));
165 if (SUCCEEDED(hr))
166 hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS, &EnumIDList);
167
168 ULONG itemcount;
169 LPITEMIDLIST pidl = NULL;
170 if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl, &itemcount)) == S_OK)
171 {
172 CoTaskMemFree(pidl);
173 iconname = L"Full";
174 } else {
175 iconname = L"Empty";
176 }
177 }
178
179 /* Prepare registry path for loading icons of My Computer and other shell extensions */
181
183 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s",
184 riid);
186 return hr;
187
188 /* Load icon for the current user */
189 BOOL ret = HCU_GetIconW(KeyName, wTemp, iconname, _countof(wTemp), &icon_idx);
190 if (!ret)
191 {
192 /* Failed, load default system-wide icon */
193 hr = FormatGUIDKey(KeyName, _countof(KeyName), L"CLSID\\%s", riid);
195 return hr;
196
197 ret = HCR_GetIconW(KeyName, wTemp, iconname, _countof(wTemp), &icon_idx);
198 }
199
200 if (ret)
201 {
202 /* Success, set loaded icon */
203 initIcon->SetNormalIcon(wTemp, icon_idx);
204 }
205 else
206 {
207 /* Everything has failed, set blank paper icon */
208 WARN("Failed to load an icon for the item, setting blank icon\n");
209 initIcon->SetNormalIcon(swShell32Name, IDI_SHELL_DOCUMENT - 1);
210 }
211
212 return initIcon->QueryInterface(iid, ppvOut);
213}
214
216 public CEnumIDListBase
217{
218 public:
221 HRESULT Initialize(LPCWSTR lpszEnumKeyName, DWORD dwFlags);
222 HRESULT AddItemsFromKey(HKEY hkey_root, LPCWSTR szRepPath);
223
225 COM_INTERFACE_ENTRY_IID(IID_IEnumIDList, IEnumIDList)
227};
228
230{
231}
232
234{
235}
236
238{
240
241 if (!(dwFlags & SHCONTF_FOLDERS))
242 return S_OK;
243
245 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\%s\\Namespace",
246 lpszEnumKeyName);
248 return hr;
249
252
253 return S_OK;
254}
255
257{
259 HKEY hkey;
260
261 if (RegOpenKeyW(hkey_root, szRepPath, &hkey) != ERROR_SUCCESS)
262 return S_FALSE;
263
264 for (int idx = 0; ; idx++)
265 {
266 if (RegEnumKeyW(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
267 break;
268
269 /* If the name of the key is not a guid try to get the default value of the key */
270 if (name[0] != L'{')
271 {
272 DWORD dwSize = sizeof(name);
274 }
275
276 if (*name == '{')
277 {
279
280 if (pidl)
281 AddToEnumList(pidl);
282 }
283 }
284
285 RegCloseKey(hkey);
286
287 return S_OK;
288}
289
290/*
291 * These columns try to map to CFSFolder's columns because the CDesktopFolder
292 * displays CFSFolder and CRegFolder items in the same view.
293 */
295{
301
303 public CComObjectRootEx<CComMultiThreadModelNoCS>,
304 public IShellFolder2
305{
306 private:
308 CAtlStringW m_rootPath;
309 CAtlStringW m_enumKeyName;
310 CComHeapPtr<ITEMIDLIST> m_pidlRoot;
311
314
315 public:
316 CRegFolder();
317 ~CRegFolder();
318 HRESULT WINAPI Initialize(const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName);
319
320 // IShellFolder
321 STDMETHOD(ParseDisplayName)(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes) override;
322 STDMETHOD(EnumObjects)(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override;
323 STDMETHOD(BindToObject)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override;
324 STDMETHOD(BindToStorage)(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override;
326 STDMETHOD(CreateViewObject)(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override;
327 STDMETHOD(GetAttributesOf)(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override;
328 STDMETHOD(GetUIObjectOf)(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut) override;
330 STDMETHOD(SetNameOf)(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override;
331
332 /* ShellFolder2 */
333 STDMETHOD(GetDefaultSearchGUID)(GUID *pguid) override;
334 STDMETHOD(EnumSearches)(IEnumExtraSearch **ppenum) override;
335 STDMETHOD(GetDefaultColumn)(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) override;
336 STDMETHOD(GetDefaultColumnState)(UINT iColumn, DWORD *pcsFlags) override;
337 STDMETHOD(GetDetailsEx)(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) override;
338 STDMETHOD(GetDetailsOf)(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) override;
340
342
344
346 COM_INTERFACE_ENTRY_IID(IID_IShellFolder2, IShellFolder2)
347 COM_INTERFACE_ENTRY_IID(IID_IShellFolder, IShellFolder)
349};
350
352{
353}
354
356{
357}
358
359HRESULT WINAPI CRegFolder::Initialize(const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName)
360{
361 memcpy(&m_guid, pGuid, sizeof(m_guid));
362
363 m_rootPath = lpszPath;
364 if (!m_rootPath)
365 return E_OUTOFMEMORY;
366
367 m_enumKeyName = lpszEnumKeyName;
368 if (!m_enumKeyName)
369 return E_OUTOFMEMORY;
370
371 m_pidlRoot.Attach(ILClone(pidlRoot));
372 if (!m_pidlRoot)
373 return E_OUTOFMEMORY;
374
375 return S_OK;
376}
377
379{
380 DWORD dwAttributes = *pdwAttributes;
381
382 /* First try to get them from the registry */
383 if (!HCR_GetFolderAttributes(pidl, pdwAttributes))
384 {
385 /* We couldn't get anything */
386 *pdwAttributes = 0;
387 }
388
389 /* Items have more attributes when on desktop */
391 {
392 *pdwAttributes |= (dwAttributes & (SFGAO_CANLINK|SFGAO_CANDELETE|SFGAO_CANRENAME|SFGAO_HASPROPSHEET));
393 }
394
395 /* In any case, links can be created */
396 *pdwAttributes |= (dwAttributes & SFGAO_CANLINK);
397 return S_OK;
398}
399
401{
403 if (IsEqualGUID(clsid, CLSID_Printers))
404 return TRUE;
405 if (IsEqualGUID(clsid, CLSID_ConnectionFolder))
406 return TRUE;
407 FIXME("Check registry\n");
408 return TRUE;
409}
410
412 ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes)
413{
414 if (!ppidl)
415 return E_INVALIDARG;
416
417 *ppidl = NULL;
418
419 if (!lpszDisplayName)
420 return E_INVALIDARG;
421
422 if (lpszDisplayName[0] != L':' || lpszDisplayName[1] != L':')
423 {
424 FIXME("What should we do here?\n");
425 return E_FAIL;
426 }
427
428 LPWSTR pch, pchNextOfComma = NULL;
429 for (pch = &lpszDisplayName[2]; *pch && *pch != L'\\'; ++pch)
430 {
431 if (*pch == L',' && !pchNextOfComma)
432 pchNextOfComma = pch + 1;
433 }
434
435 CLSID clsid;
436 if (!GUIDFromStringW(&lpszDisplayName[2], &clsid))
437 return CO_E_CLASSSTRING;
438
439 if (pchNextOfComma)
440 {
441 FIXME("Delegate folder\n");
442 return E_FAIL;
443 }
444
445 CComHeapPtr<ITEMIDLIST> pidlTemp(_ILCreateGuid(PT_GUID, clsid));
446 if (!pidlTemp)
447 return E_OUTOFMEMORY;
448
449 if (!_IsInNameSpace(pidlTemp) && !(BindCtx_GetMode(pbc, 0) & STGM_CREATE))
450 return E_INVALIDARG;
451
452 *ppidl = pidlTemp.Detach();
453
454 if (!*pch)
455 {
456 if (pdwAttributes && *pdwAttributes)
457 GetGuidItemAttributes(*ppidl, pdwAttributes);
458
459 return S_OK;
460 }
461
462 HRESULT hr = SHELL32_ParseNextElement(this, hwndOwner, pbc, ppidl, pch + 1, pchEaten,
463 pdwAttributes);
464 if (FAILED(hr))
465 {
466 ILFree(*ppidl);
467 *ppidl = NULL;
468 }
469 return hr;
470}
471
472HRESULT WINAPI CRegFolder::EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList)
473{
474 return ShellObjectCreatorInit<CRegFolderEnum>(m_enumKeyName, dwFlags, IID_PPV_ARG(IEnumIDList, ppEnumIDList));
475}
476
478{
479 CComPtr<IPersistFolder> pFolder;
480 HRESULT hr;
481
482 if (!ppvOut || !pidl || !pidl->mkid.cb)
483 return E_INVALIDARG;
484
485 *ppvOut = NULL;
486
487 GUID *pGUID = _ILGetGUIDPointer(pidl);
488 if (!pGUID)
489 {
490 ERR("CRegFolder::BindToObject called for non guid item!\n");
491 return E_INVALIDARG;
492 }
493
494 hr = SHELL32_BindToSF(m_pidlRoot, NULL, pidl, pGUID, riid, ppvOut);
496 return hr;
497
498 return S_OK;
499}
500
502{
503 return E_NOTIMPL;
504}
505
507{
508 if (!pidl1 || !pidl2 || pidl1->mkid.cb == 0 || pidl2->mkid.cb == 0)
509 {
510 ERR("Got an empty pidl!\n");
511 return E_INVALIDARG;
512 }
513
514 GUID const *clsid1 = _ILGetGUIDPointer (pidl1);
515 GUID const *clsid2 = _ILGetGUIDPointer (pidl2);
516
517 if (!clsid1 && !clsid2)
518 {
519 ERR("Got no guid pidl!\n");
520 return E_INVALIDARG;
521 }
522 else if (clsid1 && clsid2)
523 {
524 if (memcmp(clsid1, clsid2, sizeof(GUID)) == 0)
525 return SHELL32_CompareChildren(this, lParam, pidl1, pidl2);
526
527 return SHELL32_CompareDetails(this, lParam, pidl1, pidl2);
528 }
529
530 /* Guid folders come first compared to everything else */
531 /* And Drives come before folders in My Computer */
533 {
534 return MAKE_COMPARE_HRESULT(clsid1 ? 1 : -1);
535 }
536 else
537 {
538 return MAKE_COMPARE_HRESULT(clsid1 ? -1 : 1);
539 }
540}
541
543{
544 return E_NOTIMPL;
545}
546
548{
549 if (!rgfInOut || !cidl || !apidl)
550 return E_INVALIDARG;
551
552 if (*rgfInOut == 0)
553 *rgfInOut = ~0;
554
555 while(cidl > 0 && *apidl)
556 {
557 if (_ILIsSpecialFolder(*apidl))
558 GetGuidItemAttributes(*apidl, rgfInOut);
559 else
560 ERR("Got unknown pidl\n");
561 apidl++;
562 cidl--;
563 }
564
565 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
566 *rgfInOut &= ~SFGAO_VALIDATE;
567
568 return S_OK;
569}
570
572 REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
573{
574 LPVOID pObj = NULL;
576
577 if (!ppvOut)
578 return hr;
579
580 *ppvOut = NULL;
581
582 if ((IsEqualIID (riid, IID_IExtractIconA) || IsEqualIID (riid, IID_IExtractIconW)) && (cidl == 1))
583 {
584 hr = CGuidItemExtractIcon_CreateInstance(apidl[0], riid, &pObj);
585 }
586 else if (IsEqualIID (riid, IID_IContextMenu) && (cidl >= 1))
587 {
588 if (!_ILGetGUIDPointer (apidl[0]))
589 {
590 ERR("Got non guid item!\n");
591 return E_FAIL;
592 }
593
594 hr = CGuidItemContextMenu_CreateInstance(m_pidlRoot, hwndOwner, cidl, apidl, static_cast<IShellFolder*>(this), (IContextMenu**)&pObj);
595 }
596 else if (IsEqualIID (riid, IID_IDataObject) && (cidl >= 1))
597 {
598 hr = IDataObject_Constructor (hwndOwner, m_pidlRoot, apidl, cidl, TRUE, (IDataObject **)&pObj);
599 }
600 else
601 {
603 }
604
605 *ppvOut = pObj;
606 return hr;
607
608}
609
611{
612 if (!strRet || (!_ILIsSpecialFolder(pidl) && pidl != NULL))
613 return E_INVALIDARG;
614
615 if (!pidl || !pidl->mkid.cb)
616 {
618 {
620 {
621 TRACE("GDNO returning INFOLDER instead of %#x\n", GET_SHGDN_RELATION(dwFlags));
622 }
623 LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc((2 + 38 + 1) * sizeof(WCHAR));
624 if (!pszPath)
625 return E_OUTOFMEMORY;
626 /* parsing name like ::{...} */
627 pszPath[0] = ':';
628 pszPath[1] = ':';
629 SHELL32_GUIDToStringW(m_guid, &pszPath[2]);
630 strRet->uType = STRRET_WSTR;
631 strRet->pOleStr = pszPath;
632 return S_OK;
633 }
634 else
635 {
636 BOOL bRet;
637 WCHAR wstrName[MAX_PATH+1];
638 bRet = HCR_GetClassNameW(m_guid, wstrName, MAX_PATH);
639 if (!bRet)
640 return E_FAIL;
641
642 return SHSetStrRet(strRet, wstrName);
643 }
644 }
645
646 HRESULT hr;
647 GUID const *clsid = _ILGetGUIDPointer (pidl);
648
649 /* First of all check if we need to query the name from the child item */
652 {
653 int bWantsForParsing = FALSE;
654
655 /*
656 * We can only get a filesystem path from a shellfolder if the
657 * value WantsFORPARSING in CLSID\\{...}\\shellfolder exists.
658 *
659 * Exception: The MyComputer folder doesn't have this key,
660 * but any other filesystem backed folder it needs it.
661 */
662 if (IsEqualIID (*clsid, CLSID_MyComputer))
663 {
664 bWantsForParsing = TRUE;
665 }
666 else
667 {
668 HKEY hkeyClass;
669 if (HCR_RegOpenClassIDKey(*clsid, &hkeyClass))
670 {
671 LONG res = SHGetValueW(hkeyClass, L"Shellfolder", L"WantsForParsing", NULL, NULL, NULL);
672 bWantsForParsing = (res == ERROR_SUCCESS);
673 RegCloseKey(hkeyClass);
674 }
675 }
676
677 if (bWantsForParsing)
678 {
679 /*
680 * we need the filesystem path to the destination folder.
681 * Only the folder itself can know it
682 */
683 return SHELL32_GetDisplayNameOfChild (this, pidl, dwFlags, strRet);
684 }
685 }
686
687 /* Allocate the buffer for the result */
688 SIZE_T cchPath = MAX_PATH + 1;
689 LPWSTR pszPath = (LPWSTR)CoTaskMemAlloc(cchPath * sizeof(WCHAR));
690 if (!pszPath)
691 return E_OUTOFMEMORY;
692
693 hr = S_OK;
694
696 {
697 SIZE_T pathlen = 0;
698 PWCHAR pItemName = pszPath; // GET_SHGDN_RELATION(dwFlags) == SHGDN_INFOLDER
700 {
701 hr = StringCchCopyW(pszPath, cchPath, m_rootPath);
702 if (SUCCEEDED(hr))
703 {
704 pathlen = wcslen(pszPath);
705 pItemName = &pszPath[pathlen];
706 if (pathlen)
707 {
708 if (++pathlen < cchPath)
709 *pItemName++ = L'\\';
710 else
712 }
713 }
714 }
715
716 if (SUCCEEDED(hr) && pathlen + 2 + 38 + 1 < cchPath)
717 {
718 /* parsing name like ::{...} */
719 pItemName[0] = L':';
720 pItemName[1] = L':';
721 SHELL32_GUIDToStringW(*clsid, &pItemName[2]);
722 }
723 else
724 {
726 }
727 }
728 else
729 {
730 /* user friendly name */
731 if (!HCR_GetClassNameW(*clsid, pszPath, cchPath))
732 hr = E_FAIL;
733 }
734
735 if (SUCCEEDED(hr))
736 {
737 strRet->uType = STRRET_WSTR;
738 strRet->pOleStr = pszPath;
739 }
740 else
741 {
742 CoTaskMemFree(pszPath);
743 }
744
745 return hr;
746}
747
748HRESULT WINAPI CRegFolder::SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, /* simple pidl */
749 LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut)
750{
751 GUID const *clsid = _ILGetGUIDPointer (pidl);
752 LPOLESTR pStr;
753 HRESULT hr;
754 WCHAR szName[100];
755
756 if (!clsid)
757 {
758 ERR("Pidl is not reg item!\n");
759 return E_FAIL;
760 }
761
762 hr = StringFromCLSID(*clsid, &pStr);
764 return hr;
765
766 swprintf(szName, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s", pStr);
767
768 DWORD cbData = (wcslen(lpName) + 1) * sizeof(WCHAR);
770
771 CoTaskMemFree(pStr);
772
773 if (res == ERROR_SUCCESS)
774 {
775 return pPidlOut ? SHILClone(pidl, pPidlOut) : S_OK;
776 }
777
778 return E_FAIL;
779}
780
781
783{
784 return E_NOTIMPL;
785}
786
788{
789 return E_NOTIMPL;
790}
791
793{
794 if (pSort)
795 *pSort = 0;
796 if (pDisplay)
797 *pDisplay = 0;
798
799 return S_OK;
800}
801
803{
804 if (iColumn >= REGFOLDERCOLUMNCOUNT)
805 return E_INVALIDARG;
807 return S_OK;
808}
809
811{
812 return E_NOTIMPL;
813}
814
816{
817 if (!psd)
818 return E_INVALIDARG;
819
820 if (!pidl)
821 {
822 TRACE("CRegFolder has no column info\n");
823 return E_INVALIDARG;
824 }
825
826 GUID const *clsid = _ILGetGUIDPointer (pidl);
827
828 if (!clsid)
829 {
830 ERR("Pidl is not reg item!\n");
831 return E_INVALIDARG;
832 }
833
834 switch(iColumn)
835 {
836 case COL_NAME:
837 return GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
838 case COL_TYPE:
839 return SHSetStrRet(&psd->str, IDS_SYSTEMFOLDER);
840 case COL_INFOTIP:
841 HKEY hKey;
843 return SHSetStrRet(&psd->str, "");
844
845 psd->str.cStr[0] = 0x00;
846 psd->str.uType = STRRET_CSTR;
847 RegLoadMUIStringA(hKey, "InfoTip", psd->str.cStr, MAX_PATH, NULL, 0, NULL);
849 return S_OK;
850 default:
851 /* Return an empty string when we area asked for a column we don't support.
852 Only the regfolder is supposed to do this as it supports less columns compared to other folder
853 and its contents are supposed to be presented alongside items that support more columns. */
854 return SHSetStrRet(&psd->str, "");
855 }
856 return E_FAIL;
857}
858
860{
861 return E_NOTIMPL;
862}
863
864/* In latest windows version this is exported but it takes different arguments! */
865HRESULT CRegFolder_CreateInstance(const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName, REFIID riid, void **ppv)
866{
867 return ShellObjectCreatorInit<CRegFolder>(pGuid, pidlRoot, lpszPath, lpszEnumKeyName, riid, ppv);
868}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI CDefFolderMenu_Create2(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK lpfn, UINT nKeys, const HKEY *ahkeyClsKeys, IContextMenu **ppcm)
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject)
HRESULT CRegFolder_CreateInstance(const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName, REFIID riid, void **ppv)
Definition: CRegFolder.cpp:865
HRESULT CALLBACK RegFolderContextMenuCallback(IShellFolder *psf, HWND hwnd, IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: CRegFolder.cpp:25
HRESULT CGuidItemExtractIcon_CreateInstance(LPCITEMIDLIST pidl, REFIID iid, LPVOID *ppvOut)
Definition: CRegFolder.cpp:130
REGFOLDERCOLUMNINDEX
Definition: CRegFolder.cpp:295
@ REGFOLDERCOLUMNCOUNT
Definition: CRegFolder.cpp:299
@ COL_INFOTIP
Definition: CRegFolder.cpp:298
@ COL_NAME
Definition: CRegFolder.cpp:296
@ COL_TYPE
Definition: CRegFolder.cpp:297
HRESULT FormatGUIDKey(LPWSTR KeyName, SIZE_T KeySize, LPCWSTR RegPath, const GUID *riid)
Definition: CRegFolder.cpp:120
HRESULT CGuidItemContextMenu_CreateInstance(PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, IContextMenu **ppcm)
Definition: CRegFolder.cpp:87
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#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 STDMETHOD(m)
Definition: basetyps.h:62
#define RegCloseKey(hKey)
Definition: registry.h:49
BOOL AddToEnumList(LPITEMIDLIST pidl)
HRESULT Initialize(LPCWSTR lpszEnumKeyName, DWORD dwFlags)
Definition: CRegFolder.cpp:237
HRESULT AddItemsFromKey(HKEY hkey_root, LPCWSTR szRepPath)
Definition: CRegFolder.cpp:256
STDMETHOD() EnumSearches(IEnumExtraSearch **ppenum) override
Definition: CRegFolder.cpp:787
STDMETHOD() MapColumnToSCID(UINT column, SHCOLUMNID *pscid) override
Definition: CRegFolder.cpp:859
STDMETHOD() GetDefaultSearchGUID(GUID *pguid) override
Definition: CRegFolder.cpp:782
BOOL _IsInNameSpace(_In_ LPCITEMIDLIST pidl)
Definition: CRegFolder.cpp:400
STDMETHOD() CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) override
Definition: CRegFolder.cpp:506
STDMETHOD() GetDetailsEx(PCUITEMID_CHILD pidl, const SHCOLUMNID *pscid, VARIANT *pv) override
Definition: CRegFolder.cpp:810
CAtlStringW m_enumKeyName
Definition: CRegFolder.cpp:309
STDMETHOD() CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override
Definition: CRegFolder.cpp:542
CAtlStringW m_rootPath
Definition: CRegFolder.cpp:308
STDMETHOD() SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override
Definition: CRegFolder.cpp:748
STDMETHOD() GetDefaultColumn(DWORD dwRes, ULONG *pSort, ULONG *pDisplay) override
Definition: CRegFolder.cpp:792
CComHeapPtr< ITEMIDLIST > m_pidlRoot
Definition: CRegFolder.cpp:310
STDMETHOD() ParseDisplayName(HWND hwndOwner, LPBC pbc, LPOLESTR lpszDisplayName, ULONG *pchEaten, PIDLIST_RELATIVE *ppidl, ULONG *pdwAttributes) override
Definition: CRegFolder.cpp:411
STDMETHOD() GetDefaultColumnState(UINT iColumn, DWORD *pcsFlags) override
Definition: CRegFolder.cpp:802
STDMETHOD() BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override
Definition: CRegFolder.cpp:477
STDMETHOD() EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override
Definition: CRegFolder.cpp:472
STDMETHOD() GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) override
Definition: CRegFolder.cpp:610
STDMETHOD() GetDetailsOf(PCUITEMID_CHILD pidl, UINT iColumn, SHELLDETAILS *psd) override
Definition: CRegFolder.cpp:815
HRESULT GetGuidItemAttributes(LPCITEMIDLIST pidl, LPDWORD pdwAttributes)
Definition: CRegFolder.cpp:378
STDMETHOD() GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override
Definition: CRegFolder.cpp:547
STDMETHOD() GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut) override
Definition: CRegFolder.cpp:571
HRESULT WINAPI Initialize(const GUID *pGuid, LPCITEMIDLIST pidlRoot, LPCWSTR lpszPath, LPCWSTR lpszEnumKeyName)
Definition: CRegFolder.cpp:359
STDMETHOD() BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override
Definition: CRegFolder.cpp:501
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#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
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
#define GET_SHGDN_RELATION(dwFlags)
Definition: precomp.h:53
#define DFM_INVOKECOMMAND
Definition: precomp.h:45
#define GET_SHGDN_FOR(dwFlags)
Definition: precomp.h:52
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegLoadMUIStringA(IN HKEY hKey, IN LPCSTR pszValue OPTIONAL, OUT LPSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCSTR pszDirectory OPTIONAL)
Definition: reg.c:5268
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
Definition: compobj.c:2412
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define SHELL_ExecuteControlPanelCPL(hwnd, cpl)
Definition: precomp.h:156
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:246
DWORD BindCtx_GetMode(_In_ IBindCtx *pbc, _In_ DWORD dwDefault)
Definition: utils.cpp:128
EXTERN_C HRESULT SHBindToObject(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:220
HRESULT SHELL32_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdo, UINT msg)
Definition: shlfolder.cpp:522
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:13
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define swprintf
Definition: precomp.h:40
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
#define PT_GUID
static BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
FxAutoRegKey hKey
GLuint res
Definition: glext.h:9613
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:581
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:601
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:679
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:651
#define END_COM_MAP()
Definition: atlcom.h:592
#define pch(ap)
Definition: match.c:418
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static IParseDisplayName ParseDisplayName
Definition: moniker.c:816
static LPOLESTR
Definition: stg_prop.c:27
#define _In_
Definition: ms_sal.h:308
REFCLSID clsid
Definition: msctf.c:82
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
#define STGM_CREATE
Definition: objbase.h:926
interface IBindCtx * LPBC
Definition: objfwd.h:18
const GUID IID_IDataObject
BOOL WINAPI GUIDFromStringW(_In_ PCWSTR psz, _Out_ LPGUID pguid)
long LONG
Definition: pedump.c:60
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:940
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:1981
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1970
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2594
BOOL _ILIsNetHood(LPCITEMIDLIST pidl)
Definition: pidl.c:1948
LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID)
Definition: pidl.c:1766
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2292
LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid)
Definition: pidl.c:1728
static const WCHAR szName[]
Definition: powrprof.c:45
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
BOOL SH_ShowRecycleBinProperties(WCHAR sDrive)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len)
Definition: classes.c:405
BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD pdwAttributes)
Definition: classes.c:573
BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPCWSTR szName, DWORD len, int *picon_idx)
Definition: classes.c:297
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:610
HRESULT SHELL32_BindToSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidl, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: shlfolder.cpp:168
#define SHFSF_COL_COMMENT
Definition: shfldr.h:48
HRESULT SHELL32_GetDisplayNameOfChild(IShellFolder2 *psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
Definition: shlfolder.cpp:206
#define IS_SHGDN_FOR_PARSING(flags)
Definition: shfldr.h:52
#define SHFSF_COL_NAME
Definition: shfldr.h:43
HRESULT SHELL32_CompareChildren(IShellFolder2 *psf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:224
static __inline int SHELL32_GUIDToStringW(REFGUID guid, LPWSTR str)
Definition: shfldr.h:101
#define SHFSF_COL_TYPE
Definition: shfldr.h:45
LSTATUS AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:277
HRESULT SHELL32_CompareDetails(IShellFolder2 *isf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:247
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:368
BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
Definition: classes.c:236
HRESULT SHELL32_ParseNextElement(IShellFolder2 *psf, HWND hwndOwner, LPBC pbc, LPITEMIDLIST *pidlInOut, LPOLESTR szNext, DWORD *pEaten, DWORD *pdwAttributes)
Definition: shlfolder.cpp:79
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2513
HRESULT hr
Definition: shlfolder.c:183
#define DFM_CMD_PROPERTIES
Definition: shlobj.h:2611
#define IDS_SYSTEMFOLDER
Definition: shresdef.h:355
#define IDI_SHELL_DESKTOP
Definition: shresdef.h:590
#define IDI_SHELL_DOCUMENT
Definition: shresdef.h:556
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
@ STRRET_CSTR
Definition: shtypes.idl:87
@ STRRET_WSTR
Definition: shtypes.idl:85
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
@ SHCOLSTATE_TYPE_STR
Definition: shtypes.idl:121
@ SHCOLSTATE_ONBYDEFAULT
Definition: shtypes.idl:125
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
STRRET str
Definition: shtypes.idl:108
char cStr[MAX_PATH]
Definition: shtypes.idl:98
UINT uType
Definition: shtypes.idl:93
LPWSTR pOleStr
Definition: shtypes.idl:96
Definition: copy.c:22
Definition: name.c:39
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
DWORD dwAttributes
Definition: vdmdbg.h:34
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_In_ LPCSTR lpName
Definition: winbase.h:2789
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define CO_E_CLASSSTRING
Definition: winerror.h:2806
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define SW_SHOWDEFAULT
Definition: winuser.h:780
static void Initialize()
Definition: xlate.c:212
#define IID_PPV_ARG(Itype, ppType)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185