wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / msado15 / main.c
blob3479ceb5b021052c0da83747b75515b09ec1f43d
1 /*
2 * Copyright 2019 Hans Leidekker for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
20 #include "windef.h"
21 #include "winbase.h"
22 #define COBJMACROS
23 #include "objbase.h"
24 #include "rpcproxy.h"
25 #include "msdasc.h"
26 #include "msado15_backcompat.h"
28 #include "wine/debug.h"
29 #include "wine/heap.h"
31 #include "msado15_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
35 static HINSTANCE hinstance;
37 BOOL WINAPI DllMain( HINSTANCE dll, DWORD reason, LPVOID reserved )
39 switch (reason)
41 case DLL_PROCESS_ATTACH:
42 hinstance = dll;
43 DisableThreadLibraryCalls( dll );
44 break;
46 return TRUE;
49 typedef HRESULT (*fnCreateInstance)( void **obj );
51 struct msadocf
53 IClassFactory IClassFactory_iface;
54 fnCreateInstance pfnCreateInstance;
57 static inline struct msadocf *impl_from_IClassFactory( IClassFactory *iface )
59 return CONTAINING_RECORD( iface, struct msadocf, IClassFactory_iface );
62 static HRESULT WINAPI msadocf_QueryInterface( IClassFactory *iface, REFIID riid, void **obj )
64 if (IsEqualGUID( riid, &IID_IUnknown ) || IsEqualGUID( riid, &IID_IClassFactory ))
66 IClassFactory_AddRef( iface );
67 *obj = iface;
68 return S_OK;
70 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
71 return E_NOINTERFACE;
74 static ULONG WINAPI msadocf_AddRef( IClassFactory *iface )
76 return 2;
79 static ULONG WINAPI msadocf_Release( IClassFactory *iface )
81 return 1;
84 static HRESULT WINAPI msadocf_CreateInstance( IClassFactory *iface, LPUNKNOWN outer, REFIID riid, void **obj )
86 struct msadocf *cf = impl_from_IClassFactory( iface );
87 IUnknown *unknown;
88 HRESULT hr;
90 TRACE( "%p, %s, %p\n", outer, debugstr_guid(riid), obj );
92 *obj = NULL;
93 if (outer)
94 return CLASS_E_NOAGGREGATION;
96 hr = cf->pfnCreateInstance( (void **)&unknown );
97 if (FAILED(hr))
98 return hr;
100 hr = IUnknown_QueryInterface( unknown, riid, obj );
101 IUnknown_Release( unknown );
102 return hr;
105 static HRESULT WINAPI msadocf_LockServer( IClassFactory *iface, BOOL dolock )
107 FIXME( "%p, %d\n", iface, dolock );
108 return S_OK;
111 static const struct IClassFactoryVtbl msadocf_vtbl =
113 msadocf_QueryInterface,
114 msadocf_AddRef,
115 msadocf_Release,
116 msadocf_CreateInstance,
117 msadocf_LockServer
120 static struct msadocf command_cf = { { &msadocf_vtbl }, Command_create };
121 static struct msadocf connection_cf = { { &msadocf_vtbl }, Connection_create };
122 static struct msadocf recordset_cf = { { &msadocf_vtbl }, Recordset_create };
123 static struct msadocf stream_cf = { { &msadocf_vtbl }, Stream_create };
125 /***********************************************************************
126 * DllGetClassObject
128 HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj )
130 IClassFactory *cf = NULL;
132 TRACE( "%s, %s, %p\n", debugstr_guid(clsid), debugstr_guid(iid), obj );
134 if (IsEqualGUID( clsid, &CLSID_Connection ))
136 cf = &connection_cf.IClassFactory_iface;
138 else if (IsEqualGUID( clsid, &CLSID_Recordset ))
140 cf = &recordset_cf.IClassFactory_iface;
142 else if (IsEqualGUID( clsid, &CLSID_Stream ))
144 cf = &stream_cf.IClassFactory_iface;
146 else if (IsEqualGUID( clsid, &CLSID_Command ))
148 cf = &command_cf.IClassFactory_iface;
150 if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
151 return IClassFactory_QueryInterface( cf, iid, obj );
154 /******************************************************************
155 * DllCanUnloadNow
157 HRESULT WINAPI DllCanUnloadNow(void)
159 return S_FALSE;
162 /***********************************************************************
163 * DllRegisterServer
165 HRESULT WINAPI DllRegisterServer( void )
167 return __wine_register_resources( hinstance );
170 /***********************************************************************
171 * DllUnregisterServer
173 HRESULT WINAPI DllUnregisterServer( void )
175 return __wine_unregister_resources( hinstance );
178 static ITypeLib *typelib;
179 static ITypeInfo *typeinfos[LAST_tid];
181 static REFIID tid_ids[] = {
182 &IID_ADORecordsetConstruction,
183 &IID__Command,
184 &IID__Connection,
185 &IID_Field,
186 &IID_Fields,
187 &IID__Recordset,
188 &IID__Stream,
191 static HRESULT load_typelib(void)
193 HRESULT hres;
194 ITypeLib *tl;
196 if(typelib)
197 return S_OK;
199 hres = LoadRegTypeLib(&LIBID_ADODB, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
200 if(FAILED(hres)) {
201 ERR("LoadRegTypeLib failed: %08x\n", hres);
202 return hres;
205 if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
206 ITypeLib_Release(tl);
207 return hres;
210 HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
212 HRESULT hres;
214 if (FAILED(hres = load_typelib()))
215 return hres;
217 if(!typeinfos[tid]) {
218 ITypeInfo *ti;
220 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
221 if(FAILED(hres)) {
222 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
223 return hres;
226 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
227 ITypeInfo_Release(ti);
230 *typeinfo = typeinfos[tid];
231 ITypeInfo_AddRef(*typeinfo);
232 return S_OK;