21
21
#include < StringUtil.h>
22
22
#include < strsafe.h>
23
23
24
+ #include < iostream>
25
+ #include < fstream>
26
+
24
27
extern long g_cDllRef;
25
28
26
29
NCContextMenu::NCContextMenu (void )
27
30
: m_cRef(1 )
28
31
{
29
32
InterlockedIncrement (&g_cDllRef);
33
+ m_logger.open (" c:\\ test.log" );
34
+ m_logger << " hello world" << std::endl;
30
35
}
31
36
32
37
NCContextMenu::~NCContextMenu (void )
33
38
{
39
+ m_logger << " NCContextMenu::~NCContextMenu" << std::endl;
34
40
InterlockedDecrement (&g_cDllRef);
35
41
}
36
42
@@ -39,6 +45,7 @@ NCContextMenu::~NCContextMenu(void)
39
45
// Query to the interface the component supported.
40
46
IFACEMETHODIMP NCContextMenu::QueryInterface (REFIID riid, void **ppv)
41
47
{
48
+ m_logger << " NCContextMenu::QueryInterface" << std::endl;
42
49
static const QITAB qit[] =
43
50
{
44
51
QITABENT (NCContextMenu, IContextMenu),
@@ -51,12 +58,14 @@ IFACEMETHODIMP NCContextMenu::QueryInterface(REFIID riid, void **ppv)
51
58
// Increase the reference count for an interface on an object.
52
59
IFACEMETHODIMP_ (ULONG) NCContextMenu::AddRef()
53
60
{
61
+ m_logger << " NCContextMenu::AddRef" << std::endl;
54
62
return InterlockedIncrement (&m_cRef);
55
63
}
56
64
57
65
// Decrease the reference count for an interface on an object.
58
66
IFACEMETHODIMP_ (ULONG) NCContextMenu::Release()
59
67
{
68
+ m_logger << " NCContextMenu::Release" << std::endl;
60
69
ULONG cRef = InterlockedDecrement (&m_cRef);
61
70
if (0 == cRef) {
62
71
delete this ;
@@ -74,6 +83,7 @@ IFACEMETHODIMP_(ULONG) NCContextMenu::Release()
74
83
IFACEMETHODIMP NCContextMenu::Initialize (
75
84
LPCITEMIDLIST, LPDATAOBJECT pDataObj, HKEY)
76
85
{
86
+ m_logger << " NCContextMenu::Initialize" << std::endl;
77
87
m_selectedFiles.clear ();
78
88
79
89
if (!pDataObj) {
@@ -129,17 +139,20 @@ void InsertSeperator(HMENU hMenu, UINT indexMenu)
129
139
130
140
IFACEMETHODIMP NCContextMenu::QueryContextMenu (HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
131
141
{
142
+ m_logger << " NCContextMenu::QueryContextMenu" << std::endl;
132
143
// If uFlags include CMF_DEFAULTONLY then we should not do anything.
133
144
if (CMF_DEFAULTONLY & uFlags)
134
145
{
135
146
return MAKE_HRESULT (SEVERITY_SUCCESS, 0 , USHORT (0 ));
136
147
}
137
148
138
- m_info = NCClientInterface::FetchInfo (m_selectedFiles);
149
+ m_info = NCClientInterface::FetchInfo (m_selectedFiles, m_logger );
139
150
if (m_info.menuItems .empty ()) {
151
+ m_logger << " NCContextMenu::QueryContextMenu " << " empty info" << std::endl;
140
152
return MAKE_HRESULT (SEVERITY_SUCCESS, 0 , USHORT (0 ));
141
153
}
142
154
155
+ m_logger << " NCContextMenu::QueryContextMenu" << " insert separator" << std::endl;
143
156
InsertSeperator (hMenu, indexMenu++);
144
157
145
158
HMENU hSubmenu = CreateMenu ();
@@ -153,6 +166,7 @@ IFACEMETHODIMP NCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT
153
166
if (!InsertMenuItem (hMenu, indexMenu++, TRUE , &mii))
154
167
return HRESULT_FROM_WIN32 (GetLastError ());
155
168
}
169
+ m_logger << " NCContextMenu::QueryContextMenu" << " insert separator" << std::endl;
156
170
InsertSeperator (hMenu, indexMenu++);
157
171
158
172
UINT indexSubMenu = 0 ;
@@ -179,6 +193,7 @@ IFACEMETHODIMP NCContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT
179
193
180
194
IFACEMETHODIMP NCContextMenu::InvokeCommand (LPCMINVOKECOMMANDINFO pici)
181
195
{
196
+ m_logger << " NCContextMenu::InvokeCommand" << std::endl;
182
197
std::wstring command;
183
198
184
199
CMINVOKECOMMANDINFOEX *piciEx = nullptr ;
@@ -215,13 +230,14 @@ IFACEMETHODIMP NCContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO pici)
215
230
return E_FAIL;
216
231
}
217
232
218
- NCClientInterface::SendRequest (command.data (), m_selectedFiles);
233
+ NCClientInterface::SendRequest (command.data (), m_selectedFiles, m_logger );
219
234
return S_OK;
220
235
}
221
236
222
237
IFACEMETHODIMP NCContextMenu::GetCommandString (UINT_PTR idCommand,
223
238
UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax)
224
239
{
240
+ m_logger << " NCContextMenu::GetCommandString" << std::endl;
225
241
if (idCommand < m_info.menuItems .size () && uFlags == GCS_VERBW) {
226
242
return StringCchCopyW (reinterpret_cast <PWSTR>(pszName), cchMax,
227
243
m_info.menuItems [idCommand].command .data ());
0 commit comments