oleacc: Convert string table resources to po files.
[wine.git] / dlls / ddrawex / main.c
blobc93d8eb7afa5385694a0d9e86ae76ee8dd43ed6a
1 /* DirectDrawEx
3 * Copyright 2006 Ulrich Czekalla
5 * This file contains the (internal) driver registration functions,
6 * driver enumeration APIs and DirectDraw creation functions.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/debug.h"
26 #define COBJMACROS
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "objbase.h"
31 #include "rpcproxy.h"
33 #include "ddraw.h"
35 #include "initguid.h"
36 #include "ddrawex_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(ddrawex);
40 static HINSTANCE instance;
42 /*******************************************************************************
43 * IDirectDrawClassFactory::QueryInterface
45 *******************************************************************************/
46 static HRESULT WINAPI
47 IDirectDrawClassFactoryImpl_QueryInterface(IClassFactory *iface,
48 REFIID riid,
49 void **obj)
51 IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
53 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
55 if (IsEqualGUID(riid, &IID_IUnknown)
56 || IsEqualGUID(riid, &IID_IClassFactory))
58 IClassFactory_AddRef(iface);
59 *obj = This;
60 return S_OK;
63 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),obj);
64 return E_NOINTERFACE;
67 /*******************************************************************************
68 * IDirectDrawClassFactory::AddRef
70 *******************************************************************************/
71 static ULONG WINAPI
72 IDirectDrawClassFactoryImpl_AddRef(IClassFactory *iface)
74 IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
75 ULONG ref = InterlockedIncrement(&This->ref);
77 TRACE("(%p)->() incrementing from %d.\n", This, ref - 1);
79 return ref;
82 /*******************************************************************************
83 * IDirectDrawClassFactory::Release
85 *******************************************************************************/
86 static ULONG WINAPI
87 IDirectDrawClassFactoryImpl_Release(IClassFactory *iface)
89 IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
90 ULONG ref = InterlockedDecrement(&This->ref);
91 TRACE("(%p)->() decrementing from %d.\n", This, ref+1);
93 if (ref == 0)
94 HeapFree(GetProcessHeap(), 0, This);
96 return ref;
100 /*******************************************************************************
101 * IDirectDrawClassFactory::CreateInstance
103 *******************************************************************************/
104 static HRESULT WINAPI
105 IDirectDrawClassFactoryImpl_CreateInstance(IClassFactory *iface,
106 IUnknown *UnkOuter,
107 REFIID riid,
108 void **obj)
110 IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
112 TRACE("(%p)->(%p,%s,%p)\n",This,UnkOuter,debugstr_guid(riid),obj);
114 return This->pfnCreateInstance(UnkOuter, riid, obj);
117 /*******************************************************************************
118 * IDirectDrawClassFactory::LockServer
120 *******************************************************************************/
121 static HRESULT WINAPI
122 IDirectDrawClassFactoryImpl_LockServer(IClassFactory *iface,BOOL dolock)
124 IClassFactoryImpl *This = (IClassFactoryImpl*) iface;
125 FIXME("(%p)->(%d),stub!\n",This,dolock);
126 return S_OK;
130 /*******************************************************************************
131 * The class factory VTable
132 *******************************************************************************/
133 static const IClassFactoryVtbl IClassFactory_Vtbl =
135 IDirectDrawClassFactoryImpl_QueryInterface,
136 IDirectDrawClassFactoryImpl_AddRef,
137 IDirectDrawClassFactoryImpl_Release,
138 IDirectDrawClassFactoryImpl_CreateInstance,
139 IDirectDrawClassFactoryImpl_LockServer
143 /*******************************************************************************
144 * IDirectDrawFactory::QueryInterface
146 *******************************************************************************/
147 static HRESULT WINAPI
148 IDirectDrawFactoryImpl_QueryInterface(IDirectDrawFactory *iface,
149 REFIID riid,
150 void **obj)
152 IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
154 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), obj);
156 if (IsEqualGUID(riid, &IID_IUnknown)
157 || IsEqualGUID(riid, &IID_IDirectDrawFactory))
159 IDirectDrawFactory_AddRef(iface);
160 *obj = This;
161 return S_OK;
164 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),obj);
165 return E_NOINTERFACE;
168 /*******************************************************************************
169 * IDirectDrawFactory::AddRef
171 *******************************************************************************/
172 static ULONG WINAPI
173 IDirectDrawFactoryImpl_AddRef(IDirectDrawFactory *iface)
175 IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
176 ULONG ref = InterlockedIncrement(&This->ref);
178 TRACE("(%p)->() incrementing from %d.\n", This, ref - 1);
180 return ref;
183 /*******************************************************************************
184 * IDirectDrawFactory::Release
186 *******************************************************************************/
187 static ULONG WINAPI
188 IDirectDrawFactoryImpl_Release(IDirectDrawFactory *iface)
190 IDirectDrawFactoryImpl *This = (IDirectDrawFactoryImpl*) iface;
191 ULONG ref = InterlockedDecrement(&This->ref);
192 TRACE("(%p)->() decrementing from %d.\n", This, ref+1);
194 if (ref == 0)
195 HeapFree(GetProcessHeap(), 0, This);
197 return ref;
200 /*******************************************************************************
201 * IDirectDrawFactoryImpl_DirectDrawEnumerate
202 *******************************************************************************/
203 static HRESULT WINAPI
204 IDirectDrawFactoryImpl_DirectDrawEnumerate(IDirectDrawFactory* iface,
205 LPDDENUMCALLBACKW lpCallback,
206 LPVOID lpContext)
208 FIXME("Stub!\n");
209 return E_FAIL;
213 /*******************************************************************************
214 * Direct Draw Factory VTable
215 *******************************************************************************/
216 static const IDirectDrawFactoryVtbl IDirectDrawFactory_Vtbl =
218 IDirectDrawFactoryImpl_QueryInterface,
219 IDirectDrawFactoryImpl_AddRef,
220 IDirectDrawFactoryImpl_Release,
221 IDirectDrawFactoryImpl_CreateDirectDraw,
222 IDirectDrawFactoryImpl_DirectDrawEnumerate,
225 /***********************************************************************
226 * CreateDirectDrawFactory
228 ***********************************************************************/
229 static HRESULT
230 CreateDirectDrawFactory(IUnknown* UnkOuter, REFIID iid, void **obj)
232 HRESULT hr;
233 IDirectDrawFactoryImpl *This = NULL;
235 TRACE("(%p,%s,%p)\n", UnkOuter, debugstr_guid(iid), obj);
237 if (UnkOuter != NULL)
238 return CLASS_E_NOAGGREGATION;
240 This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectDrawFactoryImpl));
242 if(!This)
244 ERR("Out of memory when creating DirectDraw\n");
245 return E_OUTOFMEMORY;
248 This->lpVtbl = &IDirectDrawFactory_Vtbl;
250 hr = IDirectDrawFactory_QueryInterface((IDirectDrawFactory *)This, iid, obj);
252 if (FAILED(hr))
253 HeapFree(GetProcessHeap(), 0, This);
255 return hr;
259 /*******************************************************************************
260 * DllCanUnloadNow [DDRAWEX.@] Determines whether the DLL is in use.
262 HRESULT WINAPI DllCanUnloadNow(void)
264 return S_FALSE;
268 /*******************************************************************************
269 * DllGetClassObject [DDRAWEX.@]
271 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
273 IClassFactoryImpl *factory;
275 TRACE("ddrawex (%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
277 if (!IsEqualGUID( &IID_IClassFactory, riid)
278 && !IsEqualGUID( &IID_IUnknown, riid))
279 return E_NOINTERFACE;
281 if (!IsEqualGUID(&CLSID_DirectDrawFactory, rclsid))
283 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
284 return CLASS_E_CLASSNOTAVAILABLE;
287 factory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*factory));
288 if (factory == NULL) return E_OUTOFMEMORY;
290 factory->lpVtbl = &IClassFactory_Vtbl;
291 factory->ref = 1;
293 factory->pfnCreateInstance = CreateDirectDrawFactory;
295 *ppv = factory;
297 return S_OK;
301 /***********************************************************************
302 * DllMain
304 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD reason, LPVOID lpv)
306 switch (reason)
308 case DLL_PROCESS_ATTACH:
309 instance = hInstDLL;
310 DisableThreadLibraryCalls( hInstDLL );
311 break;
313 return TRUE;
316 /***********************************************************************
317 * DllRegisterServer (DDRAWEX.@)
319 HRESULT WINAPI DllRegisterServer(void)
321 return __wine_register_resources( instance, NULL );
324 /***********************************************************************
325 * DllUnregisterServer (DDRAWEX.@)
327 HRESULT WINAPI DllUnregisterServer(void)
329 return __wine_unregister_resources( instance, NULL );