push b25f14be0dd3305724e1f1ef337bfe2a9ff59832
[wine/hacks.git] / dlls / comcat / manager.c
blob0b80cbe75dc2dfbde779dfdf304aff6d0b3c8a13
1 /*
2 * ComCatMgr IUnknown implementation for comcat.dll
4 * Copyright (C) 2002 John K. Hohm
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.
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.
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
21 #include "comcat_private.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(ole);
27 static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface);
29 /**********************************************************************
30 * COMCAT_IUnknown_QueryInterface
32 static HRESULT WINAPI COMCAT_IUnknown_QueryInterface(
33 LPUNKNOWN iface,
34 REFIID riid,
35 LPVOID *ppvObj)
37 ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
38 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
40 if (This == NULL || ppvObj == NULL) return E_POINTER;
42 if (IsEqualGUID(riid, &IID_IUnknown)) {
43 *ppvObj = &This->unkVtbl;
44 COMCAT_IUnknown_AddRef(iface);
45 return S_OK;
48 if (IsEqualGUID(riid, &IID_ICatRegister)) {
49 *ppvObj = &This->regVtbl;
50 COMCAT_IUnknown_AddRef(iface);
51 return S_OK;
54 if (IsEqualGUID(riid, &IID_ICatInformation)) {
55 *ppvObj = &This->infVtbl;
56 COMCAT_IUnknown_AddRef(iface);
57 return S_OK;
60 return E_NOINTERFACE;
63 /**********************************************************************
64 * COMCAT_IUnknown_AddRef
66 static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface)
68 ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
69 ULONG ref;
71 TRACE("\n");
73 if (This == NULL) return E_POINTER;
75 ref = InterlockedIncrement(&This->ref);
76 if (ref == 1) {
77 InterlockedIncrement(&dll_ref);
79 return ref;
82 /**********************************************************************
83 * COMCAT_IUnknown_Release
85 static ULONG WINAPI COMCAT_IUnknown_Release(LPUNKNOWN iface)
87 ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
88 ULONG ref;
90 TRACE("\n");
92 if (This == NULL) return E_POINTER;
94 ref = InterlockedDecrement(&This->ref);
95 if (ref == 0) {
96 InterlockedDecrement(&dll_ref);
98 return ref;
101 /**********************************************************************
102 * COMCAT_IUnknown_Vtbl
104 static const IUnknownVtbl COMCAT_IUnknown_Vtbl =
106 COMCAT_IUnknown_QueryInterface,
107 COMCAT_IUnknown_AddRef,
108 COMCAT_IUnknown_Release
111 /**********************************************************************
112 * static ComCatMgr instance
114 ComCatMgrImpl COMCAT_ComCatMgr =
116 &COMCAT_IUnknown_Vtbl,
117 &COMCAT_ICatRegister_Vtbl,
118 &COMCAT_ICatInformation_Vtbl,