1 /* OLE DB Initialization
3 * Copyright 2009 Huw Davies
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
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
35 #include "oledb_private.h"
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
41 static HINSTANCE instance;
43 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID lpv)
47 case DLL_PROCESS_ATTACH:
49 DisableThreadLibraryCalls(hinst);
52 case DLL_PROCESS_DETACH:
58 /******************************************************************************
63 IClassFactory IClassFactory_iface;
64 HRESULT (*create_object)( IUnknown*, LPVOID* );
67 static inline cf *impl_from_IClassFactory(IClassFactory *iface)
69 return CONTAINING_RECORD(iface, cf, IClassFactory_iface);
72 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, void **obj)
74 cf *This = impl_from_IClassFactory(iface);
76 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);
78 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
79 IsEqualCLSID( riid, &IID_IClassFactory ) )
81 IClassFactory_AddRef( iface );
88 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
93 static ULONG WINAPI CF_Release(IClassFactory *iface)
98 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **obj)
100 cf *This = impl_from_IClassFactory(iface);
101 IUnknown *unk = NULL;
104 TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), obj);
106 r = This->create_object( pOuter, (void **) &unk );
109 r = IUnknown_QueryInterface( unk, riid, obj );
110 IUnknown_Release( unk );
115 static HRESULT WINAPI CF_LockServer(IClassFactory *iface, BOOL dolock)
117 FIXME("(%p, %d): stub\n", iface, dolock);
121 static const IClassFactoryVtbl CF_Vtbl =
130 static cf oledb_convert_cf = { { &CF_Vtbl }, create_oledb_convert };
131 static cf oledb_datainit_cf = { { &CF_Vtbl }, create_data_init };
133 /******************************************************************
136 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **obj)
138 TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
140 if ( IsEqualCLSID (rclsid, &CLSID_OLEDB_CONVERSIONLIBRARY) )
142 *obj = &oledb_convert_cf;
145 else if ( IsEqualCLSID (rclsid, &CLSID_MSDAINITIALIZE) )
147 *obj = &oledb_datainit_cf;
151 return CLASS_E_CLASSNOTAVAILABLE;
154 /******************************************************************
157 HRESULT WINAPI DllCanUnloadNow(void)
162 /***********************************************************************
165 HRESULT WINAPI DllRegisterServer(void)
167 return __wine_register_resources( instance );
170 /***********************************************************************
171 * DllUnregisterServer
173 HRESULT WINAPI DllUnregisterServer(void)
175 return __wine_unregister_resources( instance );