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
21 #include "dmband_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(dmband
);
28 IClassFactory IClassFactory_iface
;
29 HRESULT (*fnCreateInstance
)(REFIID riid
, void **ret_iface
);
32 /******************************************************************
33 * IClassFactory implementation
35 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
37 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
40 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
45 if (IsEqualGUID(&IID_IUnknown
, riid
))
46 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
47 else if (IsEqualGUID(&IID_IClassFactory
, riid
))
48 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
50 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
56 IClassFactory_AddRef(iface
);
60 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
62 return 2; /* non-heap based object */
65 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
67 return 1; /* non-heap based object */
70 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pUnkOuter
,
71 REFIID riid
, void **ppv
)
73 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
75 TRACE ("(%p, %s, %p)\n", pUnkOuter
, debugstr_dmguid(riid
), ppv
);
79 return CLASS_E_NOAGGREGATION
;
82 return This
->fnCreateInstance(riid
, ppv
);
85 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
87 TRACE("(%d)\n", dolock
);
91 static const IClassFactoryVtbl classfactory_vtbl
= {
92 ClassFactory_QueryInterface
,
95 ClassFactory_CreateInstance
,
96 ClassFactory_LockServer
99 static IClassFactoryImpl Band_CF
= {{&classfactory_vtbl
}, create_dmband
};
100 static IClassFactoryImpl BandTrack_CF
= {{&classfactory_vtbl
}, create_dmbandtrack
};
103 /******************************************************************
104 * DllGetClassObject (DMBAND.@)
108 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
110 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
112 if (IsEqualCLSID(rclsid
, &CLSID_DirectMusicBand
))
113 return IClassFactory_QueryInterface(&Band_CF
.IClassFactory_iface
, riid
, ppv
);
114 else if (IsEqualCLSID(rclsid
, &CLSID_DirectMusicBandTrack
))
115 return IClassFactory_QueryInterface(&BandTrack_CF
.IClassFactory_iface
, riid
, ppv
);
117 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid
), debugstr_dmguid(riid
), ppv
);
118 return CLASS_E_CLASSNOTAVAILABLE
;