idl:
interface _IMsgEvents : IUnknown
[id(1), helpstring("method SendMsg")] HRESULT SendMsg([in,out]SAFEARRAY(VARIANT) *ppsa);
interface IMsg : IDispatch
{
[id(1), helpstring("method SendMsg")] HRESULT SendMsg([in]SAFEARRAY(VARIANT) *ppsa);
};
HRESULT Fire_SendMsg(SAFEARRAY * * ppsa)
{
HRESULT ret;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
_IMsgEvents* p_IMsgEvents = reinterpret_cast<_IMsgEvents*>(sp.p);
if (p_IMsgEvents != NULL)
ret = p_IMsgEvents->SendMsg(ppsa);
} return ret;

}
这是客户端
BEGIN_INTERFACE_PART(server, _IMsgEvents)

STDMETHOD(GetTypeInfoCount)(unsigned int*)
{ return E_NOTIMPL; }
STDMETHOD(GetTypeInfo)(unsigned int, LCID, ITypeInfo**)
{ return E_NOTIMPL; }
STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, unsigned int, LCID, DISPID*)
{ return E_NOTIMPL; }
STDMETHOD(Invoke)(DISPID, REFIID, LCID, unsigned short, DISPPARAMS*,
  VARIANT*, EXCEPINFO*, unsigned int*)
{ return E_NOTIMPL; }
STDMETHOD(SendMsg)(SAFEARRAY **ppsa);
END_INTERFACE_PART(server)STDMETHODIMP CMYQQApp::Xserver::SendMsg(SAFEARRAY **ppsa)
{
METHOD_PROLOGUE_EX(CMYQQApp, server)
short Index;
long curId;
SAFEARRAY *psa = *ppsa;
long lUbound;
SafeArrayGetUBound(psa, 1, &lUbound);
CComBSTR cstr;
VARIANT *vr = NULL;
SafeArrayAccessData(psa, (void**)&vr);
Index = vr[0].iVal;
curId = vr[1].lVal;
SafeArrayUnaccessData(psa);
   pThis->SendMsg(ppsa);

return S_OK;
}数据可以重客户传到服务器上,就是在回调的时候,客户端接受不到数据?
这是为什么啊?
帮忙解决啊,我可以把代码发给你啊
我已经郁闷了好几天拉,分不够在加,我的MSN:[email protected]

解决方案 »

  1.   

    加 msn [email protected]
      

  2.   

    去看一下Microsoft Knowledge Base 的 Q194179。
    里面有非常好的例子和解释。
      

  3.   

    我回调没有问题啊
    STDMETHODIMP CMYQQApp::Xserver::SendMsg(SAFEARRAY **ppsa)
    {
    METHOD_PROLOGUE_EX(CMYQQApp, server)
    short Index;
    long curId;
    SAFEARRAY *psa = *ppsa;
    long lUbound;
    SafeArrayGetUBound(psa, 1, &lUbound);
    CComBSTR cstr;
    VARIANT *vr = NULL;
    SafeArrayAccessData(psa, (void**)&vr);
    Index = vr[0].iVal;
    curId = vr[1].lVal;
    SafeArrayUnaccessData(psa);
       pThis->SendMsg(ppsa);

    return S_OK;
    }
    psa为空,你说是不是数据没传过来,