我想将在dll中得到的英文字符串char类型通过sendmessage函数的wparam或者lparam传递给MFC调用程序,可是在MFC中显示出来的总是数字,我已经将wparam强制转换回char类型了,不知如何解决,请大家帮忙!

解决方案 »

  1.   

    普通的sendmessage只能发送四字节的数.
    用SendMessage(WM_COPYDATA.....试试. 具体看MSDN
      

  2.   

    如果方便的话,程序给我发过来,我看看
    最简单的就行,发送和接收消息的,别的无关的东西不要
    [email protected]
    发完了在这说一声
      

  3.   

    我是这样写的:
    发送方(dll):
    cTxtLen = GetWindowTextLength(p->hwnd); 
                 szWndName = (LPSTR) VirtualAlloc((LPVOID) NULL, 
                        (DWORD) (cTxtLen + 1), MEM_COMMIT, 
                        PAGE_READWRITE);           GetWindowText(p->hwnd, szWndName, cTxtLen + 1);        //找到接受消息窗口的名称
    COPYDATASTRUCT cpd; /*给COPYDATASTRUCT结构赋值*/
                      cpd.dwData = 0;
                      cpd.cbData = cTxtLen;
             cpd.lpData = &szWndName;
    SendMessage(g_hWnd,WM_COPYDATA,NULL,(LPARAM)&cpd);//发送!接受方(MFC):
    BOOL CSurveillantView::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    CString WndName=(LPSTR)(pCopyDataStruct->lpData);
    ...帮我看看有什么问题?
      

  4.   

    Sendmessage的第3个参数怎么写,是为0么?
      

  5.   

    WM_COPYDATA
    This message is sent when an application passes data to another application. wParam = (WPARAM)(HWND) hwnd; 
    lParam = (LPARAM)(PCOPYDATASTRUCT) pcds;
    Parameters
    hwnd 
    Handle to the window passing the data. 
    pcds 
    Pointer to a COPYDATASTRUCT structure that contains the data to be passed.