none
怎么给连接点注册接收器 RRS feed

  • 问题

  • Hi Bob:
    我在调用“Advise()”方法给“IMbnDeviceServicesEvents”接口注册接收器时返回错误: “hr = 0x80004021 : The operation attempted is not supported. ”
    关键代码如下:
    class MySink : public IMbnDeviceServicesEvents
    {
    public:
    ...
    }

    ...
        CComPtr<IMbnDeviceServicesManager>  g_DevSerMgr = NULL;
        CComPtr<IConnectionPoint>  mbnConPoint = NULL;
        CComPtr<IConnectionPointContainer>  mbnConPointCont = NULL;
        hr = CoCreateInstance(CLSID_MbnDeviceServicesManager,
                            NULL,
                            CLSCTX_ALL,
                            IID_IMbnDeviceServicesManager,
                            (void**)&g_DevSerMgr);
        hr = g_DevSerMgr->QueryInterface(IID_IConnectionPointContainer, (void**)&mbnConPointCont);
        hr = mbnConPointCont->FindConnectionPoint(IID_IMbnDeviceServicesEvents, &mbnConPoint);

        MySink* pMySink = new MySink();
        DWORD dwCookie = 0;
        IUnknown *pSinkUnk = NULL;
        hr = pMySink->QueryInterface(IID_IUnknown, (void**)&pSinkUnk);
        hr = mbnConPoint->Advise(pSinkUnk, &dwCookie); //这里返回之前提到的错误。
    ...

    2012年10月9日 2:41