[NETAPI32]
[reactos.git] / reactos / dll / shellext / shellbtrfs / contextmenu.h
1 /* Copyright (c) Mark Harmstone 2016
2 *
3 * This file is part of WinBtrfs.
4 *
5 * WinBtrfs is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public Licence as published by
7 * the Free Software Foundation, either version 3 of the Licence, or
8 * (at your option) any later version.
9 *
10 * WinBtrfs is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public Licence for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public Licence
16 * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include <shlobj.h>
19
20 extern LONG objs_loaded;
21
22 class BtrfsContextMenu : public IShellExtInit, IContextMenu {
23 public:
24 BtrfsContextMenu() {
25 refcount = 0;
26 ignore = TRUE;
27 stgm_set = FALSE;
28 InterlockedIncrement(&objs_loaded);
29 }
30
31 virtual ~BtrfsContextMenu() {
32 if (stgm_set) {
33 GlobalUnlock(stgm.hGlobal);
34 ReleaseStgMedium(&stgm);
35 }
36
37 InterlockedDecrement(&objs_loaded);
38 }
39
40 // IUnknown
41
42 HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj);
43
44 ULONG __stdcall AddRef() {
45 return InterlockedIncrement(&refcount);
46 }
47
48 ULONG __stdcall Release() {
49 LONG rc = InterlockedDecrement(&refcount);
50
51 if (rc == 0)
52 delete this;
53
54 return rc;
55 }
56
57 // IShellExtInit
58
59 virtual HRESULT __stdcall Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject* pdtobj, HKEY hkeyProgID);
60
61 // IContextMenu
62
63 virtual HRESULT __stdcall QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
64 virtual HRESULT __stdcall InvokeCommand(LPCMINVOKECOMMANDINFO pici);
65 virtual HRESULT __stdcall GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax);
66
67 private:
68 LONG refcount;
69 BOOL ignore;
70 BOOL bg;
71 WCHAR path[MAX_PATH];
72 STGMEDIUM stgm;
73 BOOL stgm_set;
74 };