From 875e58d7818bd569d99bebdc4543ee3b3bd37286 Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Thu, 2 Aug 2018 21:36:54 +0200 Subject: [PATCH] [ZIPFLDR] Add 'Extract All' menu item to the folder context menu. --- dll/shellext/zipfldr/CZipFolder.hpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/dll/shellext/zipfldr/CZipFolder.hpp b/dll/shellext/zipfldr/CZipFolder.hpp index 2b7010c4fad..74dc42107b9 100644 --- a/dll/shellext/zipfldr/CZipFolder.hpp +++ b/dll/shellext/zipfldr/CZipFolder.hpp @@ -301,10 +301,15 @@ public: return hr; } - if (riid == IID_IExplorerCommandProvider) + else if (riid == IID_IExplorerCommandProvider) { return _CExplorerCommandProvider_CreateInstance(this, riid, ppvOut); } + else if (riid == IID_IContextMenu) + { + // Folder context menu + return QueryInterface(riid, ppvOut); + } if (UnknownIID != riid) DbgPrint("%s(%S) UNHANDLED\n", __FUNCTION__, guid2string(riid)); return E_NOTIMPL; @@ -379,6 +384,7 @@ public: } else if (riid == IID_IContextMenu && cidl >= 0) { + // Context menu of an object inside the zip const ZipPidlEntry* zipEntry = _ZipFromIL(*apidl); if (zipEntry) { @@ -473,9 +479,9 @@ public: } STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO pici) { - if (!pici || pici->cbSize != sizeof(*pici)) + if (!pici || (pici->cbSize != sizeof(CMINVOKECOMMANDINFO) && pici->cbSize != sizeof(CMINVOKECOMMANDINFOEX))) return E_INVALIDARG; - + if (pici->lpVerb == MAKEINTRESOURCEA(0) || (HIWORD(pici->lpVerb) && !strcmp(pici->lpVerb, EXTRACT_VERBA))) { BSTR ZipFile = m_ZipFile.AllocSysString(); @@ -495,12 +501,18 @@ public: { int Entries = 0; - CStringW menuText(MAKEINTRESOURCEW(IDS_MENUITEM)); + if (!(uFlags & CMF_DEFAULTONLY)) + { + CStringW menuText(MAKEINTRESOURCEW(IDS_MENUITEM)); - InsertMenuW(hmenu, indexMenu++, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - Entries++; - InsertMenuW(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING, idCmdFirst++, menuText); - Entries++; + if (indexMenu) + { + InsertMenuW(hmenu, indexMenu++, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + Entries++; + } + InsertMenuW(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING, idCmdFirst++, menuText); + Entries++; + } return MAKE_HRESULT(SEVERITY_SUCCESS, 0, Entries); }