1. // 004_进程通讯_WM_COPYDATA_接收方.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
    2. //
    3. #include <windows.h>
    4. #include "resource.h"
    5. #include <atlstr.h>
    6. INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM w, LPARAM l)
    7. {
    8. switch (uMsg)
    9. {
    10. case WM_CLOSE:
    11. EndDialog(hWnd,0);
    12. break;
    13. case WM_COPYDATA:
    14. {
    15. COPYDATASTRUCT* pCds = (COPYDATASTRUCT*)l;
    16. CString buff;
    17. buff.Format(L"%x 大小:%d 数据:%s",
    18. pCds->dwData,
    19. pCds->cbData,
    20. pCds->lpData);
    21. MessageBox(hWnd, buff, L"提示", 0);
    22. }
    23. break;
    24. default:
    25. break;
    26. }
    27. return false;
    28. }
    29. int WinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd )
    30. {
    31. DialogBox(hInstance,
    32. (TCHAR*)IDD_DIALOG1,
    33. NULL,
    34. DlgProc);
    35. }