2 * Gameux library IClassFactory implementation
4 * Copyright (C) 2010 Mariusz PluciĆski
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
31 #include "gameux_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(gameux);
37 typedef HRESULT (*fnCreateInstance)(IUnknown *pUnkOuter, IUnknown **ppObj);
39 /***************************************************************
42 typedef struct _gameuxcf
44 const struct IClassFactoryVtbl *lpVtbl;
45 fnCreateInstance pfnCreateInstance;
48 static inline gameuxcf *impl_from_IClassFactory(IClassFactory *iface)
50 return (gameuxcf*)((char*)iface - FIELD_OFFSET(gameuxcf, lpVtbl));
53 static HRESULT WINAPI gameuxcf_QueryInterface(
58 TRACE("(%p, %s, %p)\n", iface, debugstr_guid(riid), ppObj);
62 if(IsEqualGUID(riid, &IID_IUnknown) ||
63 IsEqualGUID(riid, &IID_IClassFactory))
65 IClassFactory_AddRef(iface);
70 FIXME("interface %s not implemented\n", debugstr_guid(riid));
74 static ULONG WINAPI gameuxcf_AddRef(
77 TRACE("(%p)\n", iface);
81 static ULONG WINAPI gameuxcf_Release(
84 TRACE("(%p)\n", iface);
88 static HRESULT WINAPI gameuxcf_CreateInstance(
94 gameuxcf *This = impl_from_IClassFactory(iface);
98 TRACE("(%p, %p, %s, %p)\n", iface, pUnkOuter, debugstr_guid(riid), ppObj);
103 return CLASS_E_NOAGGREGATION;
105 hr = This->pfnCreateInstance(pUnkOuter, &pUnk);
109 hr = IUnknown_QueryInterface(pUnk, riid, ppObj);
110 IUnknown_Release(pUnk);
114 static HRESULT WINAPI gameuxcf_LockServer(
115 IClassFactory *iface,
118 gameuxcf *This = impl_from_IClassFactory(iface);
119 TRACE("(%p, %d)\n", This, dolock);
124 static const struct IClassFactoryVtbl gameuxcf_vtbl =
126 gameuxcf_QueryInterface,
129 gameuxcf_CreateInstance,
133 static gameuxcf gameexplorercf = { &gameuxcf_vtbl, GameExplorer_create };
134 static gameuxcf gamestatisticscf = { &gameuxcf_vtbl, GameStatistics_create };
136 /***************************************************************
137 * gameux ClassFactory
139 HRESULT WINAPI DllGetClassObject(
144 IClassFactory *cf = NULL;
146 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
148 if(IsEqualCLSID(rclsid, &CLSID_GameExplorer))
150 cf = (IClassFactory*)&gameexplorercf.lpVtbl;
152 else if( IsEqualCLSID( rclsid, &CLSID_GameStatistics ))
154 cf = (IClassFactory*) &gamestatisticscf.lpVtbl;
158 return CLASS_E_CLASSNOTAVAILABLE;
160 return IClassFactory_QueryInterface(cf, riid, ppv);