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
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 typedef HRESULT (*fnCreateInstance
)( void **obj
);
39 IClassFactory IClassFactory_iface
;
40 fnCreateInstance pfnCreateInstance
;
43 static inline struct msadocf
*impl_from_IClassFactory( IClassFactory
*iface
)
45 return CONTAINING_RECORD( iface
, struct msadocf
, IClassFactory_iface
);
48 static HRESULT WINAPI
msadocf_QueryInterface( IClassFactory
*iface
, REFIID riid
, void **obj
)
50 if (IsEqualGUID( riid
, &IID_IUnknown
) || IsEqualGUID( riid
, &IID_IClassFactory
))
52 IClassFactory_AddRef( iface
);
56 FIXME( "interface %s not implemented\n", debugstr_guid(riid
) );
60 static ULONG WINAPI
msadocf_AddRef( IClassFactory
*iface
)
65 static ULONG WINAPI
msadocf_Release( IClassFactory
*iface
)
70 static HRESULT WINAPI
msadocf_CreateInstance( IClassFactory
*iface
, LPUNKNOWN outer
, REFIID riid
, void **obj
)
72 struct msadocf
*cf
= impl_from_IClassFactory( iface
);
76 TRACE( "%p, %s, %p\n", outer
, debugstr_guid(riid
), obj
);
80 return CLASS_E_NOAGGREGATION
;
82 hr
= cf
->pfnCreateInstance( (void **)&unknown
);
86 hr
= IUnknown_QueryInterface( unknown
, riid
, obj
);
87 IUnknown_Release( unknown
);
91 static HRESULT WINAPI
msadocf_LockServer( IClassFactory
*iface
, BOOL dolock
)
93 FIXME( "%p, %d\n", iface
, dolock
);
97 static const struct IClassFactoryVtbl msadocf_vtbl
=
99 msadocf_QueryInterface
,
102 msadocf_CreateInstance
,
106 static struct msadocf command_cf
= { { &msadocf_vtbl
}, Command_create
};
107 static struct msadocf connection_cf
= { { &msadocf_vtbl
}, Connection_create
};
108 static struct msadocf recordset_cf
= { { &msadocf_vtbl
}, Recordset_create
};
109 static struct msadocf stream_cf
= { { &msadocf_vtbl
}, Stream_create
};
111 /***********************************************************************
114 HRESULT WINAPI
DllGetClassObject( REFCLSID clsid
, REFIID iid
, void **obj
)
116 IClassFactory
*cf
= NULL
;
118 TRACE( "%s, %s, %p\n", debugstr_guid(clsid
), debugstr_guid(iid
), obj
);
120 if (IsEqualGUID( clsid
, &CLSID_Connection
))
122 cf
= &connection_cf
.IClassFactory_iface
;
124 else if (IsEqualGUID( clsid
, &CLSID_Recordset
))
126 cf
= &recordset_cf
.IClassFactory_iface
;
128 else if (IsEqualGUID( clsid
, &CLSID_Stream
))
130 cf
= &stream_cf
.IClassFactory_iface
;
132 else if (IsEqualGUID( clsid
, &CLSID_Command
))
134 cf
= &command_cf
.IClassFactory_iface
;
136 if (!cf
) return CLASS_E_CLASSNOTAVAILABLE
;
137 return IClassFactory_QueryInterface( cf
, iid
, obj
);
140 static ITypeLib
*typelib
;
141 static ITypeInfo
*typeinfos
[LAST_tid
];
143 static REFIID tid_ids
[] = {
144 &IID_ADORecordsetConstruction
,
155 static HRESULT
load_typelib(void)
163 hres
= LoadRegTypeLib(&LIBID_ADODB
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &tl
);
165 ERR("LoadRegTypeLib failed: %08lx\n", hres
);
169 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
170 ITypeLib_Release(tl
);
174 HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
)
178 if (FAILED(hres
= load_typelib()))
181 if(!typeinfos
[tid
]) {
184 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
186 ERR("GetTypeInfoOfGuid(%s) failed: %08lx\n", debugstr_guid(tid_ids
[tid
]), hres
);
190 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
191 ITypeInfo_Release(ti
);
194 *typeinfo
= typeinfos
[tid
];
195 ITypeInfo_AddRef(*typeinfo
);