hhctrl.ocx: Add a missing Release call.
[wine/multimedia.git] / dlls / devenum / factory.c
blob215eb3a4c1d0c5943459e9f62de605d601c9ff3a
1 /*
2 * ClassFactory implementation for DEVENUM.dll
4 * Copyright (C) 2002 John K. Hohm
5 * Copyright (C) 2002 Robert Shearman
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "devenum_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(devenum);
28 /**********************************************************************
29 * DEVENUM_IClassFactory_QueryInterface (also IUnknown)
31 static HRESULT WINAPI DEVENUM_IClassFactory_QueryInterface(IClassFactory *iface, REFIID riid,
32 void **ppvObj)
34 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
36 if (ppvObj == NULL) return E_POINTER;
38 if (IsEqualGUID(riid, &IID_IUnknown) ||
39 IsEqualGUID(riid, &IID_IClassFactory))
41 *ppvObj = iface;
42 IClassFactory_AddRef(iface);
43 return S_OK;
45 else if (IsEqualGUID(riid, &IID_IParseDisplayName))
47 return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
50 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
51 return E_NOINTERFACE;
54 /**********************************************************************
55 * DEVENUM_IClassFactory_AddRef (also IUnknown)
57 static ULONG WINAPI DEVENUM_IClassFactory_AddRef(IClassFactory *iface)
59 TRACE("\n");
61 DEVENUM_LockModule();
63 return 2; /* non-heap based object */
66 /**********************************************************************
67 * DEVENUM_IClassFactory_Release (also IUnknown)
69 static ULONG WINAPI DEVENUM_IClassFactory_Release(IClassFactory *iface)
71 TRACE("\n");
73 DEVENUM_UnlockModule();
75 return 1; /* non-heap based object */
78 /**********************************************************************
79 * DEVENUM_IClassFactory_CreateInstance
81 static HRESULT WINAPI DEVENUM_IClassFactory_CreateInstance(IClassFactory *iface,
82 IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
84 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
86 if (ppvObj == NULL) return E_POINTER;
88 /* Don't support aggregation (Windows doesn't) */
89 if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
91 if (IsEqualGUID(&IID_ICreateDevEnum, riid))
93 *ppvObj = &DEVENUM_CreateDevEnum;
94 return S_OK;
96 if (IsEqualGUID(&IID_IParseDisplayName, riid))
98 *ppvObj = &DEVENUM_ParseDisplayName;
99 return S_OK;
102 return CLASS_E_CLASSNOTAVAILABLE;
105 /**********************************************************************
106 * DEVENUM_IClassFactory_LockServer
108 static HRESULT WINAPI DEVENUM_IClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
110 TRACE("\n");
112 if (fLock)
113 DEVENUM_LockModule();
114 else
115 DEVENUM_UnlockModule();
116 return S_OK;
119 /**********************************************************************
120 * IClassFactory_Vtbl
122 static const IClassFactoryVtbl IClassFactory_Vtbl =
124 DEVENUM_IClassFactory_QueryInterface,
125 DEVENUM_IClassFactory_AddRef,
126 DEVENUM_IClassFactory_Release,
127 DEVENUM_IClassFactory_CreateInstance,
128 DEVENUM_IClassFactory_LockServer
131 /**********************************************************************
132 * static ClassFactory instance
134 ClassFactoryImpl DEVENUM_ClassFactory = { { &IClassFactory_Vtbl } };