6 #include "systeminfo.h"
8 DWORD object_count
= 0;
12 * Standard methods for the IUnknown interface:
13 * add_ref, release, query_interface and initialize.
15 * Both of our COM objects contain pointers to the git_data object.
18 inline ULONG STDMETHODCALLTYPE
add_ref_git_data(struct git_data
*this_
)
20 return ++(this_
->count
);
23 inline ULONG STDMETHODCALLTYPE
release_git_data(struct git_data
*this_
)
25 if (--(this_
->count
) == 0) {
27 InterlockedDecrement(&object_count
);
33 inline STDMETHODIMP
query_interface_git_data(struct git_data
*this_
,
34 REFIID iid
, LPVOID FAR
*pointer
)
36 if (IsEqualIID(iid
, &IID_git_shell_ext
) ||
37 IsEqualIID(iid
, &IID_IShellExtInit
) ||
38 IsEqualIID(iid
, &IID_IUnknown
)) {
39 *pointer
= &this_
->shell_ext
;
40 } else if (IsEqualIID(iid
, &IID_git_menu
) ||
41 IsEqualIID(iid
, &IID_IContextMenu
)) {
42 *pointer
= &this_
->menu
;
46 add_ref_git_data(this_
);
50 inline STDMETHODIMP
initialize_git_data(struct git_data
*this_
,
52 LPDATAOBJECT data
, HKEY id
)
55 = {CF_HDROP
, NULL
, DVASPECT_CONTENT
, -1, TYMED_HGLOBAL
};
56 STGMEDIUM stg
= {TYMED_HGLOBAL
};
59 HRESULT result
= S_OK
;
61 /* if we can't find msysPath, don't even try to do anything else */
65 /* store the folder, if provided */
67 SHGetPathFromIDList(folder
, this_
->name
);
72 if (FAILED(data
->lpVtbl
->GetData(data
, &format
, &stg
)))
75 drop
= (HDROP
)GlobalLock(stg
.hGlobal
);
80 count
= DragQueryFile(drop
, 0xFFFFFFFF, NULL
, 0);
83 result
= E_INVALIDARG
;
84 else if (!DragQueryFile(drop
, 0, this_
->name
, sizeof(this_
->name
)))
85 result
= E_INVALIDARG
;
87 GlobalUnlock(stg
.hGlobal
);
88 ReleaseStgMedium(&stg
);
94 * Define the shell extension.
96 * Its sole purpose is to be able to query_interface() the context menu.
98 DEFINE_STANDARD_METHODS(git_shell_ext
)
100 struct git_shell_ext_virtual_table git_shell_ext_virtual_table
= {
101 query_interface_git_shell_ext
,
102 add_ref_git_shell_ext
,
103 release_git_shell_ext
,
104 initialize_git_shell_ext