我准备用发送消息的方法实现进程通讯,但是我不清楚我应该在接受进程的那个地方拦截消息。请知道的告诉我,thanks

解决方案 »

  1.   

    //是在WinMain函数里面 Main message loop:
    while (GetMessage(&msg, NULL, 0, 0)) 
    {
    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    } return msg.wParam;
    ///还是在主窗口里面?
    LRESULT CALLBACK WndProc( HWND hWnd, UINT message, 
    WPARAM wParam, LPARAM lParam )
    {
    }
      

  2.   

    实现进程通讯:
    1)可以考虑用网络的方法!比如使用一个进程建立 Server socket然后监听listen,消息有客户程序发送;这其实也是一个消息循环。
    2)对你的思路我认为应“在WinMain函数里面 Main message loop”因为B进程如何知道A进程的callback 函数哪?有一种情况是用CALLBACK 的就是使用COM组建的回调机制即事件与连接点方法。
      

  3.   

    to: xiaohedou(小黑豆) 我也希望是在winmain()里面接受消息,但是这不是窗口函数,那么非窗口函数怎么接受消息呢?
      

  4.   

    if GUI program ,you can deal message in WndProc callback function。
    if no GUI program,you can use named Event to communicate.