怎么获取其他进程postmessage的消息

如题,现在写的程序需要用到其他进程postmessage的消息。
WNDCLASSEX注册的窗口过程函数调用不到,getmessage只能获取本线程post的消息

测试代码如下:

 LRESULT CALLBACK MyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    if (1233 != uMsg)
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
    else
        std::cout << "helloworld" << lParam << std::endl;
    return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
    WNDCLASSEX wcex;
    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = MyWndProc;
    wcex.cbWndExtra = wcex.cbClsExtra = 0;
    wcex.hInstance = GetModuleHandle(NULL);
    wcex.hIcon = wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wcex.lpszMenuName = NULL;
    wcex.lpszClassName = TEXT("__HARDWARE1__");
    int x = RegisterClassEx(&wcex);
    HWND wnd = nullptr;
    wnd = CreateWindow(TEXT("__HARDWARE1__"), TEXT("HARDWARE_IMPL"), WS_POPUP,
        0, 0, 60, 60, NULL, NULL, GetModuleHandle(NULL), &x);
        int err;
    if (wnd == nullptr)
        err = GetLastError();
    std::thread a = std::thread(
        [wnd]()
    {
        while (1)
        {
            MSG msg;
            GetMessage(&msg, wnd, 0, 0);
            std::cout << "helloworld" <<
                msg.message << std::endl;
        }
    });

    while (true)
    {
        std::cin >> err;
        PostMessage(wnd, 1233, 0, err);
    }
    return 0;
}

需要用消息钩子

http://www.cnblogs.com/yincheng01/archive/2011/10/23/2311168.html

参考:http://www.cnblogs.com/findumars/p/5811644.html

如果对性能要求不是很高,可以考虑使用消息队列