1 /* DirectMusicBand 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 "dmband_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
25 static HINSTANCE instance;
26 LONG DMBAND_refCount = 0;
29 const IClassFactoryVtbl *lpVtbl;
32 /******************************************************************
33 * DirectMusicBand ClassFactory
36 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
37 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
39 if (ppobj == NULL) return E_POINTER;
44 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
47 return 2; /* non-heap based object */
50 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
51 DMBAND_UnlockModule();
53 return 1; /* non-heap based object */
56 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
57 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
59 return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
62 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
63 TRACE("(%d)\n", dolock);
68 DMBAND_UnlockModule();
73 static const IClassFactoryVtbl BandCF_Vtbl = {
74 BandCF_QueryInterface,
77 BandCF_CreateInstance,
81 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl};
84 /******************************************************************
85 * DirectMusicBandTrack ClassFactory
88 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
89 FIXME("- no interface IID: %s\n", debugstr_guid(riid));
91 if (ppobj == NULL) return E_POINTER;
96 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
99 return 2; /* non-heap based object */
102 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
103 DMBAND_UnlockModule();
105 return 1; /* non-heap based object */
108 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
109 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
111 return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
114 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
115 TRACE("(%d)\n", dolock);
120 DMBAND_UnlockModule();
125 static const IClassFactoryVtbl BandTrackCF_Vtbl = {
126 BandTrackCF_QueryInterface,
129 BandTrackCF_CreateInstance,
130 BandTrackCF_LockServer
133 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl};
135 /******************************************************************
140 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
141 if (fdwReason == DLL_PROCESS_ATTACH) {
143 DisableThreadLibraryCalls(hinstDLL);
144 /* FIXME: Initialisation */
145 } else if (fdwReason == DLL_PROCESS_DETACH) {
153 /******************************************************************
154 * DllCanUnloadNow (DMBAND.@)
158 HRESULT WINAPI DllCanUnloadNow(void)
160 return DMBAND_refCount != 0 ? S_FALSE : S_OK;
164 /******************************************************************
165 * DllGetClassObject (DMBAND.@)
169 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
171 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
173 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
175 IClassFactory_AddRef((IClassFactory*)*ppv);
177 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
178 *ppv = &BandTrack_CF;
179 IClassFactory_AddRef((IClassFactory*)*ppv);
183 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
184 return CLASS_E_CLASSNOTAVAILABLE;
187 /***********************************************************************
188 * DllRegisterServer (DMBAND.@)
190 HRESULT WINAPI DllRegisterServer(void)
192 return __wine_register_resources( instance, NULL );
195 /***********************************************************************
196 * DllUnregisterServer (DMBAND.@)
198 HRESULT WINAPI DllUnregisterServer(void)
200 return __wine_unregister_resources( instance, NULL );