a9ed1591494c1b890d5e7aa3f1faf74a4cf3d3d8
[reactos.git] / reactos / lib / 3rdparty / strmbase / dispatch.c
1 /*
2 * Generic Implementation of IDispatch for strmbase classes
3 *
4 * Copyright 2012 Aric Stewart, CodeWeavers
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "strmbase_private.h"
22
23 #include <oleauto.h>
24
25 HRESULT WINAPI BaseDispatch_Init(BaseDispatch *This, REFIID riid)
26 {
27 HRESULT hr = E_FAIL;
28 ITypeLib *pTypeLib;
29
30 This->pTypeInfo = NULL;
31 hr = LoadRegTypeLib(&LIBID_QuartzTypeLib, 1, 0, LOCALE_SYSTEM_DEFAULT, &pTypeLib);
32 if (SUCCEEDED(hr))
33 {
34 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, riid, &This->pTypeInfo);
35
36 if (pTypeLib)
37 ITypeLib_Release(pTypeLib);
38 }
39 return hr;
40 }
41
42 HRESULT WINAPI BaseDispatch_Destroy(BaseDispatch *This)
43 {
44 if (This->pTypeInfo)
45 ITypeInfo_Release(This->pTypeInfo);
46 return S_OK;
47 }
48
49 HRESULT WINAPI BaseDispatchImpl_GetIDsOfNames(BaseDispatch *This, REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)
50 {
51 if (This->pTypeInfo)
52 return ITypeInfo_GetIDsOfNames(This->pTypeInfo, rgszNames, cNames, rgdispid);
53 return E_NOTIMPL;
54 }
55
56 HRESULT WINAPI BaseDispatchImpl_GetTypeInfo(BaseDispatch *This, REFIID riid, UINT itinfo, LCID lcid, ITypeInfo **pptinfo)
57 {
58 if (This->pTypeInfo)
59 {
60 ITypeInfo_AddRef(This->pTypeInfo);
61 *pptinfo = This->pTypeInfo;
62 return S_OK;
63 }
64 return E_NOTIMPL;
65 }
66
67 HRESULT WINAPI BaseDispatchImpl_GetTypeInfoCount(BaseDispatch *This, UINT *pctinfo)
68 {
69 if (This->pTypeInfo)
70 *pctinfo = 1;
71 else
72 *pctinfo = 0;
73 return S_OK;
74 }