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
30 #include "gameux_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(gameux
);
36 typedef HRESULT (*fnCreateInstance
)(IUnknown
*pUnkOuter
, IUnknown
**ppObj
);
38 /***************************************************************
41 typedef struct _gameuxcf
43 IClassFactory IClassFactory_iface
;
44 fnCreateInstance pfnCreateInstance
;
47 static inline gameuxcf
*impl_from_IClassFactory(IClassFactory
*iface
)
49 return CONTAINING_RECORD(iface
, gameuxcf
, IClassFactory_iface
);
52 static HRESULT WINAPI
gameuxcf_QueryInterface(
57 TRACE("(%p, %s, %p)\n", iface
, debugstr_guid(riid
), ppObj
);
61 if(IsEqualGUID(riid
, &IID_IUnknown
) ||
62 IsEqualGUID(riid
, &IID_IClassFactory
))
64 IClassFactory_AddRef(iface
);
69 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
73 static ULONG WINAPI
gameuxcf_AddRef(
76 TRACE("(%p)\n", iface
);
80 static ULONG WINAPI
gameuxcf_Release(
83 TRACE("(%p)\n", iface
);
87 static HRESULT WINAPI
gameuxcf_CreateInstance(
93 gameuxcf
*This
= impl_from_IClassFactory(iface
);
97 TRACE("(%p, %p, %s, %p)\n", iface
, pUnkOuter
, debugstr_guid(riid
), ppObj
);
102 return CLASS_E_NOAGGREGATION
;
104 hr
= This
->pfnCreateInstance(pUnkOuter
, &pUnk
);
108 hr
= IUnknown_QueryInterface(pUnk
, riid
, ppObj
);
109 IUnknown_Release(pUnk
);
113 static HRESULT WINAPI
gameuxcf_LockServer(
114 IClassFactory
*iface
,
117 gameuxcf
*This
= impl_from_IClassFactory(iface
);
118 TRACE("(%p, %d)\n", This
, dolock
);
123 static const struct IClassFactoryVtbl gameuxcf_vtbl
=
125 gameuxcf_QueryInterface
,
128 gameuxcf_CreateInstance
,
132 static gameuxcf gameexplorercf
= { { &gameuxcf_vtbl
}, GameExplorer_create
};
133 static gameuxcf gamestatisticscf
= { { &gameuxcf_vtbl
}, GameStatistics_create
};
135 /***************************************************************
136 * gameux ClassFactory
138 HRESULT WINAPI
DllGetClassObject(
143 IClassFactory
*cf
= NULL
;
145 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
147 if(IsEqualCLSID(rclsid
, &CLSID_GameExplorer
))
149 cf
= &gameexplorercf
.IClassFactory_iface
;
151 else if( IsEqualCLSID( rclsid
, &CLSID_GameStatistics
))
153 cf
= &gamestatisticscf
.IClassFactory_iface
;
157 return CLASS_E_CLASSNOTAVAILABLE
;
159 return IClassFactory_QueryInterface(cf
, riid
, ppv
);