描述:
CComPtr<IWMPCore> m_spWMPPlayer;
hr = spElemDisp.QueryInterface(&m_spWMPPlayer);
if (m_spWMPPlayer!=NULL&&SUCCEEDED(hr))
{
CComPtr<IConnectionPointContainer> spConnectionContainer;
CComPtr<IWMPEvents> spEventListener;
CComPtr<IConnectionPoint> m_spConnectionPoint;
DWORD dwCookie;
m_spWMPPlayer->QueryInterface(&spConnectionContainer);
// hr = m_spWMPPlayer->QueryInterface(&spConnectionContainer);
if (FAILED(hr))
{
MessageBox(0,0,0,0);
break;
}
hr = spConnectionContainer->FindConnectionPoint(__uuidof(IWMPEvents), &m_spConnectionPoint);
if (FAILED(hr))
{
MessageBox(0,"0.1",0,0);//会出现
hr = spConnectionContainer->FindConnectionPoint(__uuidof(_WMPOCXEvents), &m_spConnectionPoint);
if (FAILED(hr))
{
MessageBox(0,"1",0,0);//会出现 TMD2个都失败了hr =E_NOINTERFACE
break;
}
}
hr = m_spConnectionPoint->Advise(spEventListener, &dwCookie);
if (FAILED(hr))
{
MessageBox(0,"2",0,0);
break;
}
CComPtr<IWMPCore> m_spWMPPlayer;可以修改属性,就是不能sink事件
解决方案1:
我没编过WMP的程序,不过很正常,也许你是版本太低,这个接口还没有。你检查下你机器上的这个版本的type library。
解决方案2:从这个错误来看:E_NOINTERFACE,表示它没有这个接口