mshtml: Use proper BINF flags for form submit.
[wine.git] / dlls / dmloader / dmloader_main.c
blobeaed6339a91ab436798638798f03836600b46409
1 /* DirectMusicLoader Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program 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 program 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 program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmloader_private.h"
21 #include "rpcproxy.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmloader);
25 static HINSTANCE instance;
26 LONG module_ref = 0;
28 typedef struct {
29 IClassFactory IClassFactory_iface;
30 HRESULT WINAPI (*fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
31 } IClassFactoryImpl;
33 /******************************************************************
34 * IClassFactory implementation
36 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
38 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
41 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
43 if (ppv == NULL)
44 return E_POINTER;
46 if (IsEqualGUID(&IID_IUnknown, riid))
47 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
48 else if (IsEqualGUID(&IID_IClassFactory, riid))
49 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
50 else {
51 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
52 *ppv = NULL;
53 return E_NOINTERFACE;
56 *ppv = iface;
57 IClassFactory_AddRef(iface);
58 return S_OK;
61 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
63 lock_module();
65 return 2; /* non-heap based object */
68 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
70 unlock_module();
72 return 1; /* non-heap based object */
75 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
76 REFIID riid, void **ppv)
78 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
80 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
82 return This->fnCreateInstance(riid, ppv, pUnkOuter);
85 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
87 TRACE("(%d)\n", dolock);
89 if (dolock)
90 lock_module();
91 else
92 unlock_module();
94 return S_OK;
97 static const IClassFactoryVtbl classfactory_vtbl = {
98 ClassFactory_QueryInterface,
99 ClassFactory_AddRef,
100 ClassFactory_Release,
101 ClassFactory_CreateInstance,
102 ClassFactory_LockServer
105 static IClassFactoryImpl dm_loader_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicLoaderImpl};
106 static IClassFactoryImpl dm_container_CF = {{&classfactory_vtbl},
107 DMUSIC_CreateDirectMusicContainerImpl};
109 /******************************************************************
110 * DllMain
112 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
113 if (fdwReason == DLL_PROCESS_ATTACH) {
114 instance = hinstDLL;
115 DisableThreadLibraryCalls(hinstDLL);
117 return TRUE;
121 /******************************************************************
122 * DllCanUnloadNow (DMLOADER.@)
124 HRESULT WINAPI DllCanUnloadNow (void)
126 TRACE("() ref=%d\n", module_ref);
128 return module_ref ? S_FALSE : S_OK;
131 /******************************************************************
132 * DllGetClassObject (DMLOADER.@)
134 HRESULT WINAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
136 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
137 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
138 IClassFactory_AddRef(&dm_loader_CF.IClassFactory_iface);
139 *ppv = &dm_loader_CF.IClassFactory_iface;
140 return S_OK;
141 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicContainer) && IsEqualIID (riid, &IID_IClassFactory)) {
142 IClassFactory_AddRef(&dm_container_CF.IClassFactory_iface);
143 *ppv = &dm_container_CF.IClassFactory_iface;
144 return S_OK;
147 WARN(": no class found\n");
148 return CLASS_E_CLASSNOTAVAILABLE;
151 /***********************************************************************
152 * DllRegisterServer (DMLOADER.@)
154 HRESULT WINAPI DllRegisterServer(void)
156 return __wine_register_resources( instance );
159 /***********************************************************************
160 * DllUnregisterServer (DMLOADER.@)
162 HRESULT WINAPI DllUnregisterServer(void)
164 return __wine_unregister_resources( instance );