没事干,看看命名管道的通信。代码是以前看孙鑫老师的VC++视频时记录下来的,现在看只是回顾一下。源代码是这样的。 void CNamedPipeSrvView::OnPipeCreate() { // TODO: Add your command handler code here hPipe = CreateNamedPipe("////.//pipe//MyPipe",PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED, 0,1,1024,1024,0,NULL); if(hPipe == INVALID_HANDLE_VALUE) { MessageBox("创建管道失败"); hPipe = NULL; return; } HANDLE hEvent; hEvent = CreateEvent(NULL,TRUE,FALSE,NULL); if(!hEvent) { MessageBox("建立事件失败"); CloseHandle(hPipe); hPipe = NULL; return; } OVERLAPPED ovlap; ZeroMemory(&ovlap,sizeof(OVERLAPPED)); ovlap.hEvent = hEvent; if(!ConnectNamedPipe(hPipe,&ovlap)) { if(ERROR_IO_PENDING != GetLastError()) { MessageBox("等待客户端连接失败"); CloseHandle(hPipe); CloseHandle(hEvent); hPipe = NULL; return; } } if(WAIT_FAILED == WaitForSingleObject(hEvent,INFINITE)) { MessageBox("等待对象失败"); CloseHandle(hPipe); CloseHandle(hEvent);