1 /* 2 * PROJECT: NT Object Namespace shell extension 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: System Registry folder class header 5 * COPYRIGHT: Copyright 2015-2017 David Quintana <gigaherz@gmail.com> 6 */ 7 8 #pragma once 9 10 extern const GUID CLSID_RegistryFolder; 11 12 class CRegistryFolderExtractIcon : 13 public CComObjectRootEx<CComMultiThreadModelNoCS>, 14 public IExtractIconW 15 { 16 PCIDLIST_ABSOLUTE m_pcidlFolder; 17 PCITEMID_CHILD m_pcidlChild; 18 19 public: 20 CRegistryFolderExtractIcon(); 21 22 virtual ~CRegistryFolderExtractIcon(); 23 24 HRESULT Initialize(LPCWSTR ntPath, PCIDLIST_ABSOLUTE parent, UINT cidl, PCUITEMID_CHILD_ARRAY apidl); 25 26 STDMETHOD(GetIconLocation)( 27 UINT uFlags, 28 LPWSTR szIconFile, 29 UINT cchMax, 30 INT *piIndex, 31 UINT *pwFlags) override; 32 33 STDMETHOD(Extract)( 34 LPCWSTR pszFile, 35 UINT nIconIndex, 36 HICON *phiconLarge, 37 HICON *phiconSmall, 38 UINT nIconSize) override; 39 40 DECLARE_NOT_AGGREGATABLE(CRegistryFolderExtractIcon) 41 DECLARE_PROTECT_FINAL_CONSTRUCT() 42 43 BEGIN_COM_MAP(CRegistryFolderExtractIcon) 44 COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW) 45 END_COM_MAP() 46 47 }; 48 49 class CRegistryFolder : 50 public CComCoClass<CRegistryFolder, &CLSID_RegistryFolder>, 51 public CCommonFolder<CRegistryFolder, RegPidlEntry, CRegistryFolderExtractIcon> 52 { 53 HKEY m_hRoot; 54 55 public: 56 DECLARE_REGISTRY_RESOURCEID(IDR_REGISTRYFOLDER) 57 58 CRegistryFolder(); 59 virtual ~CRegistryFolder(); 60 61 // IShellFolder 62 STDMETHOD(EnumObjects)( 63 HWND hwndOwner, 64 SHCONTF grfFlags, 65 IEnumIDList **ppenumIDList) override; 66 67 protected: 68 STDMETHOD(InternalBindToObject)( 69 PWSTR path, 70 const RegPidlEntry * info, 71 LPITEMIDLIST first, 72 LPCITEMIDLIST rest, 73 LPITEMIDLIST fullPidl, 74 LPBC pbcReserved, 75 IShellFolder** ppsfChild) override; 76 77 public: 78 STDMETHOD(GetDefaultColumnState)( 79 UINT iColumn, 80 SHCOLSTATEF *pcsFlags) override; 81 82 STDMETHOD(GetDetailsEx)( 83 LPCITEMIDLIST pidl, 84 const SHCOLUMNID *pscid, 85 VARIANT *pv) override; 86 87 STDMETHOD(GetDetailsOf)( 88 LPCITEMIDLIST pidl, 89 UINT iColumn, 90 SHELLDETAILS *psd) override; 91 92 STDMETHOD(MapColumnToSCID)( 93 UINT iColumn, 94 SHCOLUMNID *pscid) override; 95 96 // IPersistFolder 97 STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl) override; 98 99 // Internal 100 STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidl, PCWSTR ntPath, HKEY hRoot); 101 102 protected: 103 STDMETHOD(CompareIDs)(LPARAM lParam, const RegPidlEntry * first, const RegPidlEntry * second); 104 STDMETHOD_(ULONG, ConvertAttributes)(const RegPidlEntry * entry, PULONG inMask); 105 STDMETHOD_(BOOL, IsFolder)(const RegPidlEntry * info); 106 107 virtual HRESULT GetInfoFromPidl(LPCITEMIDLIST pcidl, const RegPidlEntry ** pentry); 108 109 HRESULT FormatValueData(DWORD contentType, PVOID td, DWORD contentsLength, PCWSTR * strContents); 110 111 HRESULT FormatContentsForDisplay(const RegPidlEntry * info, HKEY rootKey, LPCWSTR ntPath, PCWSTR * strContents); 112 }; 113