接受

BOOL bRunning=TRUE;
while(bRunning)
{
MSG msg;
DWORD dwRet = MsgWaitForMultipleObjects(0,NULL,FALSE,INFINITE,QS_ALLINPUT);
if (dwRet != WAIT_OBJECT_0) //退出
{
break;
}
while(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(!GetMessage(&msg,NULL,0,0) )
{
bRunning = FALSE;
break;
}
if (msg.message == WM_USER + 1)
{
DWORD dwID= msg.wParam;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
while(bRunning)
{
MSG msg;
DWORD dwRet = MsgWaitForMultipleObjects(0,NULL,FALSE,INFINITE,QS_ALLINPUT);
if (dwRet != WAIT_OBJECT_0) //退出
{
break;
}
while(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
{
if(!GetMessage(&msg,NULL,0,0) )
{
bRunning = FALSE;
break;
}
if (msg.message == WM_USER + 1)
{
DWORD dwID= msg.wParam;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
发送
PostThreadMessage(m_dwThreadID,WM_USER+1,dwIP,NULL);