xref: /reactos/sdk/lib/3rdparty/strmbase/dispatch.c (revision 84ccccab)
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     ITypeLib *pTypeLib;
28     HRESULT hr;
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         ITypeLib_Release(pTypeLib);
36     }
37     return hr;
38 }
39 
40 HRESULT WINAPI BaseDispatch_Destroy(BaseDispatch *This)
41 {
42     if (This->pTypeInfo)
43         ITypeInfo_Release(This->pTypeInfo);
44     return S_OK;
45 }
46 
47 HRESULT WINAPI BaseDispatchImpl_GetIDsOfNames(BaseDispatch *This, REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)
48 {
49     if (This->pTypeInfo)
50         return ITypeInfo_GetIDsOfNames(This->pTypeInfo, rgszNames, cNames, rgdispid);
51     return E_NOTIMPL;
52 }
53 
54 HRESULT WINAPI BaseDispatchImpl_GetTypeInfo(BaseDispatch *This, REFIID riid, UINT itinfo, LCID lcid, ITypeInfo **pptinfo)
55 {
56     if (This->pTypeInfo)
57     {
58         ITypeInfo_AddRef(This->pTypeInfo);
59         *pptinfo = This->pTypeInfo;
60         return S_OK;
61     }
62     return E_NOTIMPL;
63 }
64 
65 HRESULT WINAPI BaseDispatchImpl_GetTypeInfoCount(BaseDispatch *This, UINT *pctinfo)
66 {
67     if (This->pTypeInfo)
68         *pctinfo = 1;
69     else
70         *pctinfo = 0;
71     return S_OK;
72 }
73