请问收不到部分事件是怎么回事?高手帮忙~

来源:互联网  时间:2016/8/24 21:23:09

关于网友提出的“ 请问收不到部分事件是怎么回事?高手帮忙~”问题疑问,本网通过在网上对“ 请问收不到部分事件是怎么回事?高手帮忙~”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: 请问收不到部分事件是怎么回事?高手帮忙~
描述:

用empp.dll做短信发送程序,仅能收到连接成功事件,无法收到其他的如发送状态,接收短信等事件.
1。empp.tlh中_IemptclEvents 定义为
struct __declspec(uuid("c4380bfc-9918-4df7-b937-01ecc5e94e2d"))
_IemptclEvents : IDispatch
{
    //
    // Wrapper methods for error-handling
    //
    // Methods:
    HRESULT MessageReceived (
        _bstr_t MsgID,
        _bstr_t srcID,
        _bstr_t content,
        const _variant_t & submitDatetime );
    HRESULT MessageReceivedInterface (
        struct ISMDeliverd * sm );
    HRESULT StatusReceived (
        _bstr_t MsgID,
        _bstr_t DestID,
        const _variant_t & doneDatetime );
    HRESULT StatusReceivedInterface (
        struct IStatusReport * sm );
    HRESULT SubmitResp (
        _bstr_t MsgID,
        long Result,
        long SequenceID );
    HRESULT SubmitRespInterface (
        struct ISubmitResp * sm );
    HRESULT EMPPClosed (
        long errorCode );
    HRESULT SocketClosed (
        long errorCode );
    HRESULT EMPPConnected ( );
};
2。empp.tlh中代码为
inline HRESULT _IemptclEvents::MessageReceived ( _bstr_t MsgID, _bstr_t srcID, _bstr_t content, const _variant_t & submitDatetime ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x1, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0008\x0008\x0008\x000c", (BSTR)MsgID, (BSTR)srcID, (BSTR)content, &submitDatetime);
    return _result;
}
inline HRESULT _IemptclEvents::MessageReceivedInterface ( struct ISMDeliverd * sm ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x2, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0009", sm);
    return _result;
}
inline HRESULT _IemptclEvents::StatusReceived ( _bstr_t MsgID, _bstr_t DestID, const _variant_t & doneDatetime ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x3, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0008\x0008\x000c", (BSTR)MsgID, (BSTR)DestID, &doneDatetime);
    return _result;
}
inline HRESULT _IemptclEvents::StatusReceivedInterface ( struct IStatusReport * sm ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x4, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0009", sm);
    return _result;
}
inline HRESULT _IemptclEvents::SubmitResp ( _bstr_t MsgID, long Result, long SequenceID ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x5, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0008\x0003\x0003", (BSTR)MsgID, Result, SequenceID);
    return _result;
}
inline HRESULT _IemptclEvents::SubmitRespInterface ( struct ISubmitResp * sm ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x6, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0009", sm);
    return _result;
}
inline HRESULT _IemptclEvents::EMPPClosed ( long errorCode ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x7, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0003", errorCode);
    return _result;
}
inline HRESULT _IemptclEvents::SocketClosed ( long errorCode ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x8, DISPATCH_METHOD, VT_ERROR, (void*)&_result, 
        L"\x0003", errorCode);
    return _result;
}
inline HRESULT _IemptclEvents::EMPPConnected ( ) {
    HRESULT _result;
    _com_dispatch_method(this, 0x9, DISPATCH_METHOD, VT_ERROR, (void*)&_result, NULL);
    return _result;
}
3。实现接口类
static _ATL_FUNC_INFO FuncInfo = {
         CC_STDCALL,   // Calling convention.
         VT_I4,        // Return type.
         1,            // Number of arguments.
 {VT_DISPATCH }
         // Argument types.
      };//
class CEventSink:public IDispEventImpl<0, CEventSink,&DIID__IemptclEvents,&LIBID_EMPPLib, 1, 0>
{
public:
 CEventSink()
 {
 }
public:
  STDMETHOD(Invoke)(DISPID   dispidMember,REFIID   riid,   LCID   lcid,   WORD   wFlags,   
  DISPPARAMS   *   pdispparams,   VARIANT   *   pvarResult,   
  EXCEPINFO   *   pexcepinfo,   UINT   *   puArgErr)
  {
  printf("Hello\n");
 return 0;
  }
BEGIN_SINK_MAP(CEventSink)
SINK_ENTRY_INFO(0,DIID__IemptclEvents,6,SubmitRespInterface,&FuncInfo)
SINK_ENTRY_EX(0,DIID__IemptclEvents,9,EMPPConnected)
END_SINK_MAP()
STDMETHOD(SubmitRespInterface)(ISubmitRespPtr submitResp);
STDMETHOD(EMPPConnected)(); 
};
STDMETHODIMP CEventSink:: SubmitRespInterface(ISubmitRespPtr submitResp)
{
printf("收到短信发送状态 \n");
return S_OK;
}
STDMETHODIMP CEventSink::EMPPConnected()
{
printf("连接成功\n");
return S_OK;
}
4。 m_cemptcl->put_needStatus(VARIANT_TRUE);
pEventSink=new CEventSink();
if(pEventSink==NULL)
{
DEBUG_MSG("Create Event Sink..........ERROR");
}
else
{
                         DWORD dwCookie=0;
  AtlAdvise(m_cemptcl,(IUnknown*)pEventSink,  DIID__IemptclEvents,   &dwCookie);   
}
问题是程序仅在连接的时候显示连接成功,无法响应短信发送成功的代码,请高手指教.

上一篇com聚合与包容,委托与非委托
下一篇急求类似netmeeting的软件的开发方法
明星图片
相关文章
《 请问收不到部分事件是怎么回事?高手帮忙~》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)