2 * Copyright 2014 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wmp_private.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(wmp
);
27 HINSTANCE wmp_instance
;
28 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
30 static REFIID tid_ids
[] = {
31 #define XIID(iface) &IID_ ## iface,
32 #define CTID(name) &CLSID_ ## name,
38 static ITypeLib
*typelib
;
39 static ITypeInfo
*typeinfos
[LAST_tid
];
41 static HRESULT
load_typelib(void)
46 hr
= LoadRegTypeLib(&LIBID_WMPLib
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &tl
);
48 ERR("LoadRegTypeLib failed: %08x\n", hr
);
52 if (InterlockedCompareExchangePointer((void **)&typelib
, tl
, NULL
))
57 HRESULT
get_typeinfo(typeinfo_id tid
, ITypeInfo
**typeinfo
)
66 if (!typeinfos
[tid
]) {
69 hr
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
71 ERR("GetTypeInfoOfGuid (%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hr
);
75 if (InterlockedCompareExchangePointer((void **)(typeinfos
+ tid
), ti
, NULL
))
76 ITypeInfo_Release(ti
);
79 *typeinfo
= typeinfos
[tid
];
80 ITypeInfo_AddRef(*typeinfo
);
84 static void release_typelib(void)
88 for (i
= 0; i
< ARRAY_SIZE(typeinfos
); i
++)
90 ITypeInfo_Release(typeinfos
[i
]);
92 ITypeLib_Release(typelib
);
95 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
99 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
100 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
102 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
103 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
108 IUnknown_AddRef((IUnknown
*)*ppv
);
112 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
113 return E_NOINTERFACE
;
116 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
118 TRACE("(%p)\n", iface
);
122 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
124 TRACE("(%p)\n", iface
);
128 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
130 TRACE("(%p)->(%x)\n", iface
, fLock
);
134 static const IClassFactoryVtbl WMPFactoryVtbl
= {
135 ClassFactory_QueryInterface
,
137 ClassFactory_Release
,
138 WMPFactory_CreateInstance
,
139 ClassFactory_LockServer
142 static IClassFactory WMPFactory
= { &WMPFactoryVtbl
};
144 /******************************************************************
147 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
149 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
152 case DLL_PROCESS_ATTACH
:
153 DisableThreadLibraryCalls(hInstDLL
);
154 wmp_instance
= hInstDLL
;
156 case DLL_PROCESS_DETACH
:
157 unregister_wmp_class();
158 unregister_player_msg_class();
166 /***********************************************************************
167 * DllGetClassObject (wmp.@)
169 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
171 if(IsEqualGUID(&CLSID_WindowsMediaPlayer
, rclsid
)) {
172 TRACE("(CLSID_WindowsMediaPlayer %s %p)\n", debugstr_guid(riid
), ppv
);
173 return IClassFactory_QueryInterface(&WMPFactory
, riid
, ppv
);
176 FIXME("Unknown object %s\n", debugstr_guid(rclsid
));
177 return CLASS_E_CLASSNOTAVAILABLE
;
180 /***********************************************************************
181 * DllCanUnloadNow (wmp.@)
183 HRESULT WINAPI
DllCanUnloadNow(void)
189 /***********************************************************************
190 * DllRegisterServer (wmp.@)
192 HRESULT WINAPI
DllRegisterServer(void)
195 return __wine_register_resources(wmp_instance
);
198 /***********************************************************************
199 * DllUnregisterServer (wmp.@)
201 HRESULT WINAPI
DllUnregisterServer(void)
204 return __wine_unregister_resources(wmp_instance
);