我用ATL写控件,通过发消息SendMessage把参数结构体的指针送出来,消息响应函数触发连接点机制
SendMessage(m_hWnd, WM_INFO_RET, (WPARAM)&recvInfo, (LPARAM)&msgRef);
消息响应函数
HRESULT CMyCtrl::OnInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
Fire_OnGetInfo((char*)wParam, (char*)lParam);
return 0;
}
我想控件暴露给外面的事件接口OnGetInfo(char* pInfo, char* pMsgRef),用户收到这两个指针就好
可是为char* 指针,控件根本就不给OnGetInfo事件
如果换成void*,显示OnGetInfo,可是根本收不到消息(控件内部肯定发消息出来),并且编译控件就有两处警告
如果用OnGetInfo(long pInfo, long pMsgRef),在外面强制转换成指针,一切正常,但指针类型用long 表示,哪也太,,,
请问,如何把指针传出来,并且用户看到的接口上也是*

解决方案 »

  1.   

    你为什么不用BSTR 呢?OnGetInfo(BSTR *pInfo, BSTR *pMsgRef),
      

  2.   

    好像不行吧,编译有4个警告
    warning C4800: 'unsigned short ** ' : forcing value to bool 'true' or 'false' (performance warning)
            f:\xsatlctrl\xsatlctrlcp.h(48) : while compiling class-template member function 'long __thiscall CProxy_IXSNetCtrlEvents<class CXSNetCtrl>::Fire_OnGetDrvInfo(unsigned short ** ,unsigned short ** )'
    f:\xsatlctrl\xsatlctrlcp.h(65) : warning C4800: 'unsigned short ** ' : forcing value to bool 'true' or 'false' (performance warning)
            f:\xsatlctrl\xsatlctrlcp.h(48) : while compiling class-template member function 'long __thiscall CProxy_IXSNetCtrlEvents<class CXSNetCtrl>::Fire_OnGetDrvInfo(unsigned short ** ,unsigned short ** )'
      

  3.   

    com的参数传递不应该是char,而应该是BSTR,你的警告信息原因是没有使用好BSTR,而不是BSTR有问题,检查一下程序,看看BSTR是怎么使用的