ntdll: Make sure we don't try to attach the main exe a second time.
[wine/zf.git] / dlls / dplayx / dpclassfactory.c
blob6accab68d7c3c9d2cfa9226bb7c50561ff0d9bca
1 /* COM class factory for direct play lobby interfaces.
3 * Copyright 1999, 2000 Peter Hunnisett
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include <string.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "objbase.h"
29 #include "winerror.h"
30 #include "wine/debug.h"
31 #include "dplay.h"
32 #include "dplobby.h"
33 #include "initguid.h"
34 #include "dplay_global.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dplay);
39 typedef struct
41 IClassFactory IClassFactory_iface;
42 HRESULT (*createinstance)(REFIID riid, void **ppv);
43 } IClassFactoryImpl;
45 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
47 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
50 static HRESULT WINAPI IClassFactoryImpl_QueryInterface(IClassFactory *iface, REFIID riid,
51 void **ppv)
53 TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
55 if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid))
57 *ppv = iface;
58 IClassFactory_AddRef(iface);
59 return S_OK;
62 *ppv = NULL;
63 WARN("no interface for %s\n", debugstr_guid(riid));
64 return E_NOINTERFACE;
67 static ULONG WINAPI IClassFactoryImpl_AddRef(IClassFactory *iface)
69 return 2; /* non-heap based object */
72 static ULONG WINAPI IClassFactoryImpl_Release(IClassFactory *iface)
74 return 1; /* non-heap based object */
77 static HRESULT WINAPI IClassFactoryImpl_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
78 REFIID riid, void **ppv)
80 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
82 TRACE("(%p)->(%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid), ppv);
84 if (pOuter)
85 return CLASS_E_NOAGGREGATION;
87 return This->createinstance(riid, ppv);
90 static HRESULT WINAPI IClassFactoryImpl_LockServer(IClassFactory *iface, BOOL dolock)
92 FIXME("(%p)->(%d),stub!\n", iface, dolock);
93 return S_OK;
96 static const IClassFactoryVtbl cf_vt = {
97 IClassFactoryImpl_QueryInterface,
98 IClassFactoryImpl_AddRef,
99 IClassFactoryImpl_Release,
100 IClassFactoryImpl_CreateInstance,
101 IClassFactoryImpl_LockServer
104 static IClassFactoryImpl dplay_cf = {{&cf_vt}, dplay_create};
105 static IClassFactoryImpl dplaylobby_cf = {{&cf_vt}, dplobby_create};
108 /*******************************************************************************
109 * DllGetClassObject [DPLAYX.@]
110 * Retrieves DP or DPL class object from a DLL object
112 * NOTES
113 * Docs say returns STDAPI
115 * PARAMS
116 * rclsid [I] CLSID for the class object
117 * riid [I] Reference to identifier of interface for class object
118 * ppv [O] Address of variable to receive interface pointer for riid
120 * RETURNS
121 * Success: S_OK
122 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
123 * E_UNEXPECTED
125 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
127 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
129 if (IsEqualCLSID(&CLSID_DirectPlay, rclsid))
130 return IClassFactory_QueryInterface(&dplay_cf.IClassFactory_iface, riid, ppv);
132 if (IsEqualCLSID(&CLSID_DirectPlayLobby, rclsid))
133 return IClassFactory_QueryInterface(&dplaylobby_cf.IClassFactory_iface, riid, ppv);
135 FIXME("(%s,%s,%p): no class found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
136 return CLASS_E_CLASSNOTAVAILABLE;