[ZIPFLDR] Add 'Extract All' menu item to the folder context menu.
authorMark Jansen <mark.jansen@reactos.org>
Thu, 2 Aug 2018 19:36:54 +0000 (21:36 +0200)
committerMark Jansen <mark.jansen@reactos.org>
Sun, 5 Aug 2018 09:54:56 +0000 (11:54 +0200)
dll/shellext/zipfldr/CZipFolder.hpp

index 2b7010c..74dc421 100644 (file)
@@ -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);
     }