push ac4b6ebdd3fd886d6a18959265755579ed195b88
[wine/hacks.git] / dlls / msdaps / main.c
blob1312fc4166ec655b90a4b9f3b9378a45658c3877
1 /*
2 * msdaps initialisation.
4 * Copyright 2010 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include <string.h>
23 #define COBJMACROS
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "winerror.h"
32 #include "objbase.h"
33 #include "oleauto.h"
34 #define DBINITCONSTANTS
35 #include "oledb.h"
37 #include "row_server.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
43 extern BOOL WINAPI msdaps_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
44 extern HRESULT WINAPI msdaps_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
45 extern HRESULT WINAPI msdaps_DllCanUnloadNow(void) DECLSPEC_HIDDEN;
47 /*****************************************************************************
48 * DllMain
50 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
52 return msdaps_DllMain(instance, reason, reserved);
56 /******************************************************************************
57 * ClassFactory
59 typedef struct
61 const IClassFactoryVtbl *lpVtbl;
62 HRESULT (*create_object)( IUnknown*, LPVOID* );
63 } cf;
65 static HRESULT WINAPI CF_QueryInterface(IClassFactory *iface, REFIID riid, void **obj)
67 cf *This = (cf *)iface;
69 TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), obj);
71 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
72 IsEqualCLSID( riid, &IID_IClassFactory ) )
74 IClassFactory_AddRef( iface );
75 *obj = iface;
76 return S_OK;
78 return E_NOINTERFACE;
81 static ULONG WINAPI CF_AddRef(IClassFactory *iface)
83 return 2;
86 static ULONG WINAPI CF_Release(IClassFactory *iface)
88 return 1;
91 static HRESULT WINAPI CF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **obj)
93 cf *This = (cf *)iface;
94 IUnknown *unk = NULL;
95 HRESULT r;
97 TRACE("(%p, %p, %s, %p)\n", This, pOuter, debugstr_guid(riid), obj);
99 r = This->create_object( pOuter, (void **) &unk );
100 if (SUCCEEDED(r))
102 r = IUnknown_QueryInterface( unk, riid, obj );
103 IUnknown_Release( unk );
105 return r;
108 static HRESULT WINAPI CF_LockServer(IClassFactory *iface, BOOL dolock)
110 FIXME("(%p, %d): stub\n", iface, dolock);
111 return S_OK;
114 static const IClassFactoryVtbl CF_Vtbl =
116 CF_QueryInterface,
117 CF_AddRef,
118 CF_Release,
119 CF_CreateInstance,
120 CF_LockServer
123 static cf row_server_cf = { &CF_Vtbl, create_row_server };
124 static cf row_proxy_cf = { &CF_Vtbl, create_row_marshal };
125 static cf rowset_server_cf = { &CF_Vtbl, create_rowset_server };
126 static cf rowset_proxy_cf = { &CF_Vtbl, create_rowset_marshal };
128 /***********************************************************************
129 * DllGetClassObject
131 HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *obj)
133 TRACE("(%s, %s, %p)\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
135 if (IsEqualCLSID(clsid, &CLSID_wine_row_server))
137 *obj = &row_server_cf;
138 return S_OK;
141 if (IsEqualCLSID(clsid, &CLSID_wine_row_proxy))
143 *obj = &row_proxy_cf;
144 return S_OK;
147 if (IsEqualCLSID(clsid, &CLSID_wine_rowset_server))
149 *obj = &rowset_server_cf;
150 return S_OK;
153 if (IsEqualCLSID(clsid, &CLSID_wine_rowset_proxy))
155 *obj = &rowset_proxy_cf;
156 return S_OK;
159 return msdaps_DllGetClassObject(clsid, iid, obj);
162 /***********************************************************************
163 * DllCanUnloadNow
165 HRESULT WINAPI DllCanUnloadNow(void)
167 return msdaps_DllCanUnloadNow();