标签:
1 // 消息发送处消息打包与发送的过程 2 COPYDATASTRUCT cs; 3 FilesList FileInfo; // 待发送的数据,为一结构体,大小为 2624 字节 4 5 // 给结构体 FileInfo + cs 赋值 6 ...... 7 cs.lpData = &FileInfo; 8 9 // 消息发送 10 if(NULL != hServer) 11 { 12 ::SendMessage(hServer,WM_COPYDATA,256,(LPARAM)&cs); 13 } 14 15 if(NULL != hClient) 16 { 17 ::SendMessage(hClient,WM_COPYDATA,126,(LPARAM)&cs); 18 } 19 20 // Server 消息接收 21 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 22 { 23 ...... 24 25 switch (message) 26 { 27 case WM_COPYDATA: 28 // Leo 出错时下面这句 LOG 有输入: [Agent]WndProc - message received from test app: 0x4A(256,738496) 29 RETAILMSG(1,(L"[Client]%s - message received from server: 0x%X(%d,%d)\r\n",CString(__FUNCTION__),message,wParam,lParam)); 30 { 31 if(TRUE == ProcessMsgRcved(message,wParam,lParam)) 32 { 33 ...... 34 } 35 else 36 { 37 ...... 38 } 39 } 40 break; 41 ...... 42 default: 43 return DefWindowProc(hWnd, message, wParam, lParam); 44 } 45 return 0; 46 } 47 48 BOOL ProcessMsgRcved(UINT message,WPARAM wParam,LPARAM lParam) 49 { 50 BOOL bRet = TRUE; 51 52 switch(message) 53 { 54 case WM_COPYDATA: 55 { 56 COPYDATASTRUCT *pCs = (COPYDATASTRUCT *)lParam; 57 // 由 LOG: [Agent]WndProc - message received from test app: 0x4A(256,738496) 知 pCs 不为空。 58 if(NULL != pCs) 59 { 60 // Leo 出错时没有下面这句 LOG 输入 61 // 按程序正常的流程,应该走到此句 LOG 才对! 62 RETAILMSG(1,(L"[Server]WM_COPYDATA - %d,%d,0x%X\r\n",pCs->dwData,pCs->cbData,pCs->lpData)); 63 64 ...... 65 } 66 } 67 } 68 }
标签:
原文地址:http://www.cnblogs.com/91program/p/5205055.html