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