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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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(
36 ICOM_THIS(ClassFactoryImpl, iface);
37 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
39 if (This == NULL || ppvObj == NULL) return E_POINTER;
41 if (IsEqualGUID(riid, &IID_IUnknown) ||
42 IsEqualGUID(riid, &IID_IClassFactory))
44 *ppvObj = (LPVOID)iface;
45 IClassFactory_AddRef(iface);
48 else if (IsEqualGUID(riid, &IID_IParseDisplayName))
50 return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
53 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
57 /**********************************************************************
58 * DEVENUM_IClassFactory_AddRef (also IUnknown)
60 static ULONG WINAPI DEVENUM_IClassFactory_AddRef(LPCLASSFACTORY iface)
62 ICOM_THIS(ClassFactoryImpl, iface);
65 if (This == NULL) return E_POINTER;
69 if (InterlockedIncrement(&This->ref) == 1) {
70 InterlockedIncrement(&dll_ref);
75 /**********************************************************************
76 * DEVENUM_IClassFactory_Release (also IUnknown)
78 static ULONG WINAPI DEVENUM_IClassFactory_Release(LPCLASSFACTORY iface)
80 ICOM_THIS(ClassFactoryImpl, iface);
83 if (This == NULL) return E_POINTER;
85 if (InterlockedDecrement(&This->ref) == 0) {
86 InterlockedDecrement(&dll_ref);
91 /**********************************************************************
92 * DEVENUM_IClassFactory_CreateInstance
94 static HRESULT WINAPI DEVENUM_IClassFactory_CreateInstance(
100 ICOM_THIS(ClassFactoryImpl, iface);
101 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
103 if (This == NULL || ppvObj == NULL) return E_POINTER;
105 /* Don't support aggregation (Windows doesn't) */
106 if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
108 if (IsEqualGUID(&IID_ICreateDevEnum, riid))
110 *ppvObj = &DEVENUM_CreateDevEnum;
113 if (IsEqualGUID(&IID_IParseDisplayName, riid))
115 *ppvObj = &DEVENUM_ParseDisplayName;
119 return CLASS_E_CLASSNOTAVAILABLE;
122 /**********************************************************************
123 * DEVENUM_IClassFactory_LockServer
125 static HRESULT WINAPI DEVENUM_IClassFactory_LockServer(
126 LPCLASSFACTORY iface,
131 if (fLock != FALSE) {
132 IClassFactory_AddRef(iface);
134 IClassFactory_Release(iface);
139 /**********************************************************************
142 static ICOM_VTABLE(IClassFactory) IClassFactory_Vtbl =
144 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
145 DEVENUM_IClassFactory_QueryInterface,
146 DEVENUM_IClassFactory_AddRef,
147 DEVENUM_IClassFactory_Release,
148 DEVENUM_IClassFactory_CreateInstance,
149 DEVENUM_IClassFactory_LockServer
152 /**********************************************************************
153 * static ClassFactory instance
155 ClassFactoryImpl DEVENUM_ClassFactory = { &IClassFactory_Vtbl, 0 };