user32/tests: Add a regression test for CreateIconFromResource.
[wine] / dlls / dmband / dmband_main.c
CommitLineData
473c5657
RM
1/* DirectMusicBand Main
2 *
0382ea1d 3 * Copyright (C) 2003-2004 Rok Mandeljc
473c5657 4 *
7718d2bd
AJ
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.
473c5657
RM
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7718d2bd
AJ
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
473c5657 14 *
7718d2bd
AJ
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
473c5657
RM
18 */
19
20#include "dmband_private.h"
21
df167d17 22WINE_DEFAULT_DEBUG_CHANNEL(dmband);
473c5657 23
7946edf2
JH
24LONG DMBAND_refCount = 0;
25
0382ea1d 26typedef struct {
247246ed 27 const IClassFactoryVtbl *lpVtbl;
473c5657
RM
28} IClassFactoryImpl;
29
df167d17
RM
30/******************************************************************
31 * DirectMusicBand ClassFactory
32 */
33
0382ea1d 34static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
7946edf2
JH
35 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
36
37 if (ppobj == NULL) return E_POINTER;
38
473c5657
RM
39 return E_NOINTERFACE;
40}
41
0382ea1d 42static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
7946edf2
JH
43 DMBAND_LockModule();
44
45 return 2; /* non-heap based object */
473c5657
RM
46}
47
0382ea1d 48static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
7946edf2
JH
49 DMBAND_UnlockModule();
50
51 return 1; /* non-heap based object */
473c5657
RM
52}
53
0382ea1d 54static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
7946edf2
JH
55 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
56
0382ea1d 57 return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
df167d17
RM
58}
59
0382ea1d 60static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
7946edf2
JH
61 TRACE("(%d)\n", dolock);
62
63 if (dolock)
64 DMBAND_LockModule();
65 else
66 DMBAND_UnlockModule();
67
df167d17
RM
68 return S_OK;
69}
473c5657 70
247246ed 71static const IClassFactoryVtbl BandCF_Vtbl = {
df167d17
RM
72 BandCF_QueryInterface,
73 BandCF_AddRef,
74 BandCF_Release,
75 BandCF_CreateInstance,
76 BandCF_LockServer
77};
78
7946edf2 79static IClassFactoryImpl Band_CF = {&BandCF_Vtbl};
df167d17
RM
80
81
82/******************************************************************
83 * DirectMusicBandTrack ClassFactory
84 */
85
0382ea1d 86static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
7946edf2
JH
87 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
88
89 if (ppobj == NULL) return E_POINTER;
90
df167d17
RM
91 return E_NOINTERFACE;
92}
93
0382ea1d 94static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
7946edf2
JH
95 DMBAND_LockModule();
96
97 return 2; /* non-heap based object */
df167d17
RM
98}
99
0382ea1d 100static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
7946edf2
JH
101 DMBAND_UnlockModule();
102
103 return 1; /* non-heap based object */
df167d17
RM
104}
105
0382ea1d 106static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
7946edf2
JH
107 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
108
0382ea1d 109 return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
473c5657
RM
110}
111
0382ea1d 112static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
7946edf2
JH
113 TRACE("(%d)\n", dolock);
114
115 if (dolock)
116 DMBAND_LockModule();
117 else
118 DMBAND_UnlockModule();
119
473c5657
RM
120 return S_OK;
121}
122
247246ed 123static const IClassFactoryVtbl BandTrackCF_Vtbl = {
df167d17
RM
124 BandTrackCF_QueryInterface,
125 BandTrackCF_AddRef,
126 BandTrackCF_Release,
127 BandTrackCF_CreateInstance,
128 BandTrackCF_LockServer
473c5657
RM
129};
130
7946edf2 131static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl};
473c5657
RM
132
133/******************************************************************
134 * DllMain
135 *
136 *
137 */
0382ea1d
RM
138BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
139 if (fdwReason == DLL_PROCESS_ATTACH) {
473c5657
RM
140 DisableThreadLibraryCalls(hinstDLL);
141 /* FIXME: Initialisation */
0382ea1d 142 } else if (fdwReason == DLL_PROCESS_DETACH) {
473c5657
RM
143 /* FIXME: Cleanup */
144 }
145
146 return TRUE;
147}
148
149
150/******************************************************************
1de5d3cc 151 * DllCanUnloadNow (DMBAND.@)
473c5657
RM
152 *
153 *
154 */
d37f0abf
AJ
155HRESULT WINAPI DllCanUnloadNow(void)
156{
7946edf2 157 return DMBAND_refCount != 0 ? S_FALSE : S_OK;
473c5657
RM
158}
159
160
161/******************************************************************
21e3ba8c 162 * DllGetClassObject (DMBAND.@)
473c5657
RM
163 *
164 *
165 */
d37f0abf
AJ
166HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
167{
b26d65bb 168 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
df167d17
RM
169
170 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
171 *ppv = (LPVOID) &Band_CF;
172 IClassFactory_AddRef((IClassFactory*)*ppv);
173 return S_OK;
174 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
175 *ppv = (LPVOID) &BandTrack_CF;
176 IClassFactory_AddRef((IClassFactory*)*ppv);
177 return S_OK;
178 }
179
b26d65bb 180 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
473c5657
RM
181 return CLASS_E_CLASSNOTAVAILABLE;
182}