I am working on a small application. I want to embed the ActiveX Control and want to remote it in a mfc application. For I need a IServiceProvider Interface of COM. IServiceProvider gives the access of IWMPRemoteMediaAccess interface.
For that I am using this:
But It returnes E_INVALIDARG every time. Can anyone tell me what could be the problem.
IOleObject* oleObject;
CComPtr<IServiceProvider> m_spProvider;
CComPtr<IWMPRemoteMediaServices> m_spServices;
HRESULT hr = CoCreateInstance(__uuidof(WindowsMediaPlayer), 0, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&oleObject);
hr = oleObject->QueryInterface(__uuidof(IServiceProvider), (void**)&m_spProvider);
if(SUCCEEDED(hr))
{
//Here It return E_INVALIDARG (hr = E_INVALID_ARG)
hr = m_spProvider->QueryService(__uuidof(IWMPRemoteMediaServices), IID_IServiceProvider, (void**)&m_spServices);
}
I am not able to understand which argument is wrong. I more sure about first argument. can anyone tell me what it could be.
Thank You
IWMPRemoteMediaServicesis the interface you are supposed to implement on your side, not to query viaQueryService. MSDN:Then WMP will call methods of this interface, methods that you implement. The code you are showing is an attempt to obtain WMP's
IServiceProviderand services that the control implements. Vice versa, this is what WMP will do - it will discover services that you implement.See RemoteHost.h and RemoteHost.cpp here on how your classes should look like.