StrRetToStrNAW returns ok on NT4, though it should return FALSE.
[wine] / dlls / dmband / dmband_main.c
1 /* DirectMusicBand Main
2  *
3  * Copyright (C) 2003-2004 Rok Mandeljc
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #include "dmband_private.h"
21
22 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
23
24 LONG DMBAND_refCount = 0;
25
26 typedef struct {
27     IClassFactoryVtbl          *lpVtbl;
28 } IClassFactoryImpl;
29
30 /******************************************************************
31  *              DirectMusicBand ClassFactory
32  */
33  
34 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
35         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
36
37         if (ppobj == NULL) return E_POINTER;
38         
39         return E_NOINTERFACE;
40 }
41
42 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
43         DMBAND_LockModule();
44
45         return 2; /* non-heap based object */
46 }
47
48 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
49         DMBAND_UnlockModule();
50
51         return 1; /* non-heap based object */
52 }
53
54 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
55         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
56         
57         return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
58 }
59
60 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
61         TRACE("(%d)\n", dolock);
62
63         if (dolock)
64                 DMBAND_LockModule();
65         else
66                 DMBAND_UnlockModule();
67         
68         return S_OK;
69 }
70
71 static IClassFactoryVtbl BandCF_Vtbl = {
72         BandCF_QueryInterface,
73         BandCF_AddRef,
74         BandCF_Release,
75         BandCF_CreateInstance,
76         BandCF_LockServer
77 };
78
79 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl};
80
81
82 /******************************************************************
83  *              DirectMusicBandTrack ClassFactory
84  */
85  
86 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87         FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
88         
89         if (ppobj == NULL) return E_POINTER;
90         
91         return E_NOINTERFACE;
92 }
93
94 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
95         DMBAND_LockModule();
96
97         return 2; /* non-heap based object */
98 }
99
100 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
101         DMBAND_UnlockModule();
102
103         return 1; /* non-heap based object */
104 }
105
106 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107         TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
108         
109         return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
110 }
111
112 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113         TRACE("(%d)\n", dolock);
114
115         if (dolock)
116                 DMBAND_LockModule();
117         else
118                 DMBAND_UnlockModule();
119         
120         return S_OK;
121 }
122
123 static IClassFactoryVtbl BandTrackCF_Vtbl = {
124         BandTrackCF_QueryInterface,
125         BandTrackCF_AddRef,
126         BandTrackCF_Release,
127         BandTrackCF_CreateInstance,
128         BandTrackCF_LockServer
129 };
130
131 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl};
132
133 /******************************************************************
134  *              DllMain
135  *
136  *
137  */
138 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
139         if (fdwReason == DLL_PROCESS_ATTACH) {
140             DisableThreadLibraryCalls(hinstDLL);
141                 /* FIXME: Initialisation */
142         } else if (fdwReason == DLL_PROCESS_DETACH) {
143                 /* FIXME: Cleanup */
144         }
145
146         return TRUE;
147 }
148
149
150 /******************************************************************
151  *              DllCanUnloadNow (DMBAND.1)
152  *
153  *
154  */
155 HRESULT WINAPI DMBAND_DllCanUnloadNow(void) {
156         return DMBAND_refCount != 0 ? S_FALSE : S_OK;
157 }
158
159
160 /******************************************************************
161  *              DllGetClassObject (DMBAND.2)
162  *
163  *
164  */
165 HRESULT WINAPI DMBAND_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) {
166     TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
167
168         if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
169                 *ppv = (LPVOID) &Band_CF;
170                 IClassFactory_AddRef((IClassFactory*)*ppv);
171                 return S_OK;
172         } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
173                 *ppv = (LPVOID) &BandTrack_CF;
174                 IClassFactory_AddRef((IClassFactory*)*ppv);
175                 return S_OK;    
176         }
177         
178     WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
179     return CLASS_E_CLASSNOTAVAILABLE;
180 }