7 DWORD object_count
= 0;
11 * Standard methods for the IUnknown interface:
12 * add_ref, release, query_interface and initialize.
14 * Both of our COM objects contain pointers to the git_data object.
17 inline ULONG STDMETHODCALLTYPE
add_ref_git_data(struct git_data
*this_
)
19 return ++(this_
->count
);
22 inline ULONG STDMETHODCALLTYPE
release_git_data(struct git_data
*this_
)
24 if (--(this_
->count
) == 0) {
26 InterlockedDecrement(&object_count
);
32 inline STDMETHODIMP
query_interface_git_data(struct git_data
*this_
,
33 REFIID iid
, LPVOID FAR
*pointer
)
35 if (IsEqualIID(iid
, &IID_git_shell_ext
) ||
36 IsEqualIID(iid
, &IID_IShellExtInit
) ||
37 IsEqualIID(iid
, &IID_IUnknown
)) {
38 *pointer
= &this_
->shell_ext
;
39 } else if (IsEqualIID(iid
, &IID_git_menu
) ||
40 IsEqualIID(iid
, &IID_IContextMenu
)) {
41 *pointer
= &this_
->menu
;
45 add_ref_git_data(this_
);
49 inline STDMETHODIMP
initialize_git_data(struct git_data
*this_
,
51 LPDATAOBJECT data
, HKEY id
)
54 = {CF_HDROP
, NULL
, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
55 STGMEDIUM stg
= {TYMED_HGLOBAL
};
58 HRESULT result
= S_OK
;
63 if (FAILED(data
->lpVtbl
->GetData(data
, &format
, &stg
)))
66 drop
= (HDROP
)GlobalLock(stg
.hGlobal
);
71 count
= DragQueryFile(drop
, 0xFFFFFFFF, NULL
, 0);
74 result
= E_INVALIDARG
;
75 else if (!DragQueryFile(drop
, 0, this_
->name
, sizeof(this_
->name
)))
76 result
= E_INVALIDARG
;
78 GlobalUnlock(stg
.hGlobal
);
79 ReleaseStgMedium(&stg
);
85 * Define the shell extension.
87 * Its sole purpose is to be able to query_interface() the context menu.
89 DEFINE_STANDARD_METHODS(git_shell_ext
)
91 struct git_shell_ext_virtual_table git_shell_ext_virtual_table
= {
92 query_interface_git_shell_ext
,
93 add_ref_git_shell_ext
,
94 release_git_shell_ext
,
95 initialize_git_shell_ext