1 /* 2 * provides new shell item service 3 * 4 * Copyright 2007 Johannes Anderwald (johannes.anderwald@reactos.org) 5 * Copyright 2009 Andrew Hill 6 * Copyright 2012 Rafal Harabien 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 21 */ 22 23 #ifndef _SHV_ITEM_NEW_H_ 24 #define _SHV_ITEM_NEW_H_ 25 26 const WCHAR ShellNewKey[] = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Discardable\\PostSetup\\ShellNew"; 27 28 class CNewMenu : 29 public CComCoClass<CNewMenu, &CLSID_NewMenu>, 30 public CComObjectRootEx<CComMultiThreadModelNoCS>, 31 public IObjectWithSite, 32 public IContextMenu3, 33 public IShellExtInit 34 { 35 private: 36 enum SHELLNEW_TYPE 37 { 38 SHELLNEW_TYPE_INVALID = -1, 39 SHELLNEW_TYPE_COMMAND = 1, 40 SHELLNEW_TYPE_DATA = 2, 41 SHELLNEW_TYPE_FILENAME = 4, 42 SHELLNEW_TYPE_NULLFILE = 8 43 }; 44 45 struct SHELLNEW_ITEM 46 { 47 SHELLNEW_TYPE Type; 48 LPWSTR pwszExt; 49 PBYTE pData; 50 ULONG cbData; 51 LPWSTR pwszDesc; 52 HICON hIcon; 53 SHELLNEW_ITEM *pNext; 54 }; 55 56 LPITEMIDLIST m_pidlFolder; 57 LPWSTR m_wszPath; 58 SHELLNEW_ITEM *m_pItems; 59 SHELLNEW_ITEM *m_pLinkItem; 60 CComPtr<IUnknown> m_pSite; 61 HMENU m_hSubMenu; 62 HICON m_hiconFolder, m_hiconLink; 63 64 SHELLNEW_ITEM *LoadItem(LPCWSTR pwszExt); 65 void UnloadItem(SHELLNEW_ITEM *pItem); 66 void UnloadAllItems(); 67 BOOL CacheItems(); 68 BOOL LoadCachedItems(); 69 BOOL LoadAllItems(); 70 UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu); 71 SHELLNEW_ITEM *FindItemFromIdOffset(UINT IdOffset); 72 HRESULT CreateNewFolder(LPCMINVOKECOMMANDINFO lpici); 73 HRESULT CreateNewItem(SHELLNEW_ITEM *pItem, LPCMINVOKECOMMANDINFO lpcmi); 74 HRESULT SelectNewItem(LONG wEventId, UINT uFlags, LPWSTR pszName); 75 76 public: 77 CNewMenu(); 78 ~CNewMenu(); 79 80 // IObjectWithSite 81 virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *pUnkSite); 82 virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID riid, void **ppvSite); 83 84 // IContextMenu 85 virtual HRESULT WINAPI QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); 86 virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi); 87 virtual HRESULT WINAPI GetCommandString(UINT_PTR idCommand, UINT uFlags, UINT *lpReserved, LPSTR lpszName, UINT uMaxNameLen); 88 89 // IContextMenu3 90 virtual HRESULT WINAPI HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult); 91 92 // IContextMenu2 93 virtual HRESULT WINAPI HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam); 94 95 // IShellExtInit 96 virtual HRESULT STDMETHODCALLTYPE Initialize(LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID); 97 98 DECLARE_REGISTRY_RESOURCEID(IDR_NEWMENU) 99 DECLARE_NOT_AGGREGATABLE(CNewMenu) 100 101 DECLARE_PROTECT_FINAL_CONSTRUCT() 102 103 BEGIN_COM_MAP(CNewMenu) 104 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 105 COM_INTERFACE_ENTRY_IID(IID_IContextMenu3, IContextMenu3) 106 COM_INTERFACE_ENTRY_IID(IID_IContextMenu2, IContextMenu2) 107 COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) 108 COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit) 109 END_COM_MAP() 110 }; 111 112 #endif /* _SHV_ITEM_NEW_H_ */ 113