4 #include "menuengine.h"
7 #include "systeminfo.h"
9 DWORD object_count
= 0;
13 * Standard methods for the IUnknown interface:
14 * add_ref, release, query_interface and initialize.
16 * Both of our COM objects contain pointers to the git_data object.
19 inline ULONG STDMETHODCALLTYPE
add_ref_git_data(struct git_data
*this_
)
21 return ++(this_
->count
);
24 inline ULONG STDMETHODCALLTYPE
release_git_data(struct git_data
*this_
)
26 if (--(this_
->count
) == 0) {
28 InterlockedDecrement(&object_count
);
34 inline STDMETHODIMP
query_interface_git_data(struct git_data
*this_
,
35 REFIID iid
, LPVOID FAR
*pointer
)
37 if (IsEqualIID(iid
, &IID_git_shell_ext
) ||
38 IsEqualIID(iid
, &IID_IShellExtInit
) ||
39 IsEqualIID(iid
, &IID_IUnknown
)) {
40 *pointer
= &this_
->shell_ext
;
41 } else if (IsEqualIID(iid
, &IID_git_menu
) ||
42 IsEqualIID(iid
, &IID_IContextMenu
)) {
43 *pointer
= &this_
->menu
;
47 add_ref_git_data(this_
);
51 inline STDMETHODIMP
initialize_git_data(struct git_data
*this_
,
53 LPDATAOBJECT data
, HKEY id
)
56 = {CF_HDROP
, NULL
, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
57 STGMEDIUM stg
= {TYMED_HGLOBAL
};
60 HRESULT result
= S_OK
;
62 /* if we can't find msysPath, don't even try to do anything else */
66 /* store the folder, if provided */
68 SHGetPathFromIDList(folder
, this_
->name
);
73 if (FAILED(data
->lpVtbl
->GetData(data
, &format
, &stg
)))
76 drop
= (HDROP
)GlobalLock(stg
.hGlobal
);
81 count
= DragQueryFile(drop
, 0xFFFFFFFF, NULL
, 0);
84 result
= E_INVALIDARG
;
85 else if (!DragQueryFile(drop
, 0, this_
->name
, sizeof(this_
->name
)))
86 result
= E_INVALIDARG
;
88 GlobalUnlock(stg
.hGlobal
);
89 ReleaseStgMedium(&stg
);
95 * Define the shell extension.
97 * Its sole purpose is to be able to query_interface() the context menu.
99 DEFINE_STANDARD_METHODS(git_shell_ext
)
101 struct git_shell_ext_virtual_table git_shell_ext_virtual_table
= {
102 query_interface_git_shell_ext
,
103 add_ref_git_shell_ext
,
104 release_git_shell_ext
,
105 initialize_git_shell_ext