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: %08lx\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: %08lx\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
]);
93 ITypeLib_Release(typelib
);
96 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
100 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
101 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
103 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
104 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
109 IUnknown_AddRef((IUnknown
*)*ppv
);
113 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
114 return E_NOINTERFACE
;
117 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
119 TRACE("(%p)\n", iface
);
123 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
125 TRACE("(%p)\n", iface
);
129 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
131 TRACE("(%p)->(%x)\n", iface
, fLock
);
135 static const IClassFactoryVtbl WMPFactoryVtbl
= {
136 ClassFactory_QueryInterface
,
138 ClassFactory_Release
,
139 WMPFactory_CreateInstance
,
140 ClassFactory_LockServer
143 static IClassFactory WMPFactory
= { &WMPFactoryVtbl
};
145 /******************************************************************
148 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
150 TRACE("(%p %ld %p)\n", hInstDLL
, fdwReason
, lpv
);
153 case DLL_PROCESS_ATTACH
:
154 DisableThreadLibraryCalls(hInstDLL
);
155 wmp_instance
= hInstDLL
;
157 case DLL_PROCESS_DETACH
:
159 unregister_wmp_class();
160 unregister_player_msg_class();
168 /***********************************************************************
169 * DllGetClassObject (wmp.@)
171 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
173 if(IsEqualGUID(&CLSID_WindowsMediaPlayer
, rclsid
)) {
174 TRACE("(CLSID_WindowsMediaPlayer %s %p)\n", debugstr_guid(riid
), ppv
);
175 return IClassFactory_QueryInterface(&WMPFactory
, riid
, ppv
);
178 FIXME("Unknown object %s\n", debugstr_guid(rclsid
));
179 return CLASS_E_CLASSNOTAVAILABLE
;