ReactOS 0.4.16-dev-106-g10b08aa
CExplorerCommand.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Zip Shell Extension
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: IExplorerCommand implementation
5 * COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#include "precomp.h"
9
11 public CComObjectRootEx<CComMultiThreadModelNoCS>,
12 public IExplorerCommand
13{
14private:
16
17public:
18
20 {
21 m_pZipObject = zipObject;
22 return S_OK;
23 }
24
25 // *** IExplorerCommand methods ***
26 STDMETHODIMP GetTitle(IShellItemArray *psiItemArray, PWSTR *ppszName)
27 {
29 return SHStrDup(Title, ppszName);
30 }
31 STDMETHODIMP GetIcon(IShellItemArray *psiItemArray, PWSTR *ppszIcon)
32 {
33 CStringW IconName = L"zipfldr.dll,-1";
34 return SHStrDup(IconName, ppszIcon);
35 }
36 STDMETHODIMP GetToolTip(IShellItemArray *psiItemArray, PWSTR *ppszInfotip)
37 {
39 return SHStrDup(HelpText, ppszInfotip);
40 }
42 {
43 *pguidCommandName = CLSID_ZipFolderExtractAllCommand;
44 return S_OK;
45 }
46 STDMETHODIMP GetState(IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
47 {
48 *pCmdState = ECS_ENABLED;
49 return S_OK;
50 }
51 STDMETHODIMP Invoke(IShellItemArray *psiItemArray, IBindCtx *pbc)
52 {
53 CMINVOKECOMMANDINFO cm = { sizeof(cm), 0 };
54 cm.lpVerb = EXTRACT_VERBA;
55 cm.nShow = SW_SHOW;
56 return m_pZipObject->InvokeCommand(&cm);
57 }
58 STDMETHODIMP GetFlags(EXPCMDFLAGS *pFlags)
59 {
60 *pFlags = ECF_DEFAULT;
61 return S_OK;
62 }
63 STDMETHODIMP EnumSubCommands(IEnumExplorerCommand **ppEnum)
64 {
65 DbgPrint("%s\n", __FUNCTION__);
66 return E_NOTIMPL;
67 }
68
69public:
72
74 COM_INTERFACE_ENTRY_IID(IID_IExplorerCommand, IExplorerCommand)
76};
77
78
81 public IEnumExplorerCommand
82{
83private:
86
87public:
88
90 :m_bFirst(true)
91 {
92 }
93
95 {
96 m_pZipObject = zipObject;
97 return S_OK;
98 }
99
100 // *** IEnumExplorerCommand methods ***
101 STDMETHODIMP Next(ULONG celt, IExplorerCommand **pUICommand, ULONG *pceltFetched)
102 {
103 if (!pUICommand)
104 return E_POINTER;
105
106 if (pceltFetched)
107 *pceltFetched = 0;
108 if (m_bFirst && celt)
109 {
110 m_bFirst = false;
111 celt--;
112 HRESULT hr = ShellObjectCreatorInit<CExplorerCommand>(m_pZipObject, IID_PPV_ARG(IExplorerCommand, pUICommand));
113 if (SUCCEEDED(hr))
114 {
115 if (pceltFetched)
116 *pceltFetched = 1;
117 }
118 return hr;
119 }
120 return S_FALSE;
121 }
123 {
124 if (m_bFirst)
125 {
126 m_bFirst = false;
127 return S_OK;
128 }
129 return S_FALSE;
130 }
132 {
133 m_bFirst = true;
134 return S_OK;
135 }
136 STDMETHODIMP Clone(IEnumExplorerCommand **ppenum)
137 {
138 return E_NOTIMPL;
139 }
140
141public:
144
146 COM_INTERFACE_ENTRY_IID(IID_IEnumExplorerCommand, IEnumExplorerCommand)
148};
149
152 public IExplorerCommandProvider
153{
154private:
156
157public:
159 {
160 m_pZipObject = zipObject;
161 return S_OK;
162 }
163
164 // *** IExplorerCommandProvider methods ***
166 {
167 return ShellObjectCreatorInit<CEnumExplorerCommand>(m_pZipObject, riid, ppv);
168 }
169 STDMETHODIMP GetCommand(REFGUID rguidCommandId, REFIID riid, void **ppv)
170 {
172 *ppv = NULL;
173 return E_NOTIMPL;
174 }
175
176public:
179
181 COM_INTERFACE_ENTRY_IID(IID_IExplorerCommandProvider, IExplorerCommandProvider)
183};
184
185
187{
188 return ShellObjectCreatorInit<CExplorerCommandProvider>(zipObject, riid, ppvOut);
189}
HRESULT _CExplorerCommandProvider_CreateInstance(IContextMenu *zipObject, REFIID riid, LPVOID *ppvOut)
const WCHAR * class
Definition: main.c:68
#define STDMETHODIMP
Definition: basetyps.h:43
#define UNIMPLEMENTED
Definition: debug.h:118
STDMETHODIMP Initialize(IContextMenu *zipObject)
STDMETHODIMP Next(ULONG celt, IExplorerCommand **pUICommand, ULONG *pceltFetched)
STDMETHODIMP Clone(IEnumExplorerCommand **ppenum)
STDMETHODIMP Skip(ULONG celt)
CComPtr< IContextMenu > m_pZipObject
STDMETHODIMP GetCommands(IUnknown *punkSite, REFIID riid, void **ppv)
STDMETHODIMP Initialize(IContextMenu *zipObject)
STDMETHODIMP GetCommand(REFGUID rguidCommandId, REFIID riid, void **ppv)
CComPtr< IContextMenu > m_pZipObject
STDMETHODIMP GetToolTip(IShellItemArray *psiItemArray, PWSTR *ppszInfotip)
STDMETHODIMP EnumSubCommands(IEnumExplorerCommand **ppEnum)
STDMETHODIMP GetIcon(IShellItemArray *psiItemArray, PWSTR *ppszIcon)
STDMETHODIMP Initialize(IContextMenu *zipObject)
STDMETHODIMP GetFlags(EXPCMDFLAGS *pFlags)
STDMETHODIMP GetTitle(IShellItemArray *psiItemArray, PWSTR *ppszName)
CComPtr< IContextMenu > m_pZipObject
STDMETHODIMP Invoke(IShellItemArray *psiItemArray, IBindCtx *pbc)
STDMETHODIMP GetCanonicalName(GUID *pguidCommandName)
STDMETHODIMP GetState(IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState)
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
LPCTSTR IconName
Definition: desktop.c:53
EXTERN_C const GUID CLSID_ZipFolderExtractAllCommand
Definition: precomp.h:34
#define EXTRACT_VERBA
Definition: precomp.h:25
#define IDS_MENUITEM
Definition: resource.h:73
#define IDS_HELPTEXT
Definition: resource.h:74
static const WCHAR Title[]
Definition: oid.c:1259
#define __FUNCTION__
Definition: types.h:116
unsigned int BOOL
Definition: ntddk_ex.h:94
#define DbgPrint
Definition: hal.h:12
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#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 L(x)
Definition: ntvdm.h:50
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define SHStrDup
Definition: shlwapi.h:1537
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:606
#define true
Definition: stdbool.h:36
Definition: scsiwmi.h:51
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365
#define SW_SHOW
Definition: winuser.h:778
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IID_PPV_ARG(Itype, ppType)