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 /**********************************************************************
25 * DEVENUM_IClassFactory_QueryInterface (also IUnknown)
27 static HRESULT WINAPI
DEVENUM_IClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
,
30 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObj
);
32 if (ppvObj
== NULL
) return E_POINTER
;
34 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
35 IsEqualGUID(riid
, &IID_IClassFactory
))
38 IClassFactory_AddRef(iface
);
41 else if (IsEqualGUID(riid
, &IID_IParseDisplayName
))
43 return IClassFactory_CreateInstance(iface
, NULL
, riid
, ppvObj
);
46 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
50 /**********************************************************************
51 * DEVENUM_IClassFactory_AddRef (also IUnknown)
53 static ULONG WINAPI
DEVENUM_IClassFactory_AddRef(IClassFactory
*iface
)
59 return 2; /* non-heap based object */
62 /**********************************************************************
63 * DEVENUM_IClassFactory_Release (also IUnknown)
65 static ULONG WINAPI
DEVENUM_IClassFactory_Release(IClassFactory
*iface
)
69 DEVENUM_UnlockModule();
71 return 1; /* non-heap based object */
74 /**********************************************************************
75 * DEVENUM_IClassFactory_CreateInstance
77 static HRESULT WINAPI
DEVENUM_IClassFactory_CreateInstance(IClassFactory
*iface
,
78 IUnknown
*pUnkOuter
, REFIID riid
, void **ppvObj
)
80 TRACE("(%p)->(%p, %s, %p)\n", iface
, pUnkOuter
, debugstr_guid(riid
), ppvObj
);
82 if (ppvObj
== NULL
) return E_POINTER
;
84 /* Don't support aggregation (Windows doesn't) */
85 if (pUnkOuter
!= NULL
) return CLASS_E_NOAGGREGATION
;
87 if (IsEqualGUID(&IID_ICreateDevEnum
, riid
))
89 *ppvObj
= &DEVENUM_CreateDevEnum
;
92 if (IsEqualGUID(&IID_IParseDisplayName
, riid
))
94 *ppvObj
= &DEVENUM_ParseDisplayName
;
98 return CLASS_E_CLASSNOTAVAILABLE
;
101 /**********************************************************************
102 * DEVENUM_IClassFactory_LockServer
104 static HRESULT WINAPI
DEVENUM_IClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
109 DEVENUM_LockModule();
111 DEVENUM_UnlockModule();
115 /**********************************************************************
118 static const IClassFactoryVtbl IClassFactory_Vtbl
=
120 DEVENUM_IClassFactory_QueryInterface
,
121 DEVENUM_IClassFactory_AddRef
,
122 DEVENUM_IClassFactory_Release
,
123 DEVENUM_IClassFactory_CreateInstance
,
124 DEVENUM_IClassFactory_LockServer
127 /**********************************************************************
128 * static ClassFactory instance
130 ClassFactoryImpl DEVENUM_ClassFactory
= { { &IClassFactory_Vtbl
} };