0
即使我之前調用了CreateNamedPipe,我仍然掛在WaitNamedPipe函數上。由於waitnamedpipe函數只是等待管道的啓動,爲什麼?代碼如下。感謝命名管道,服務器問題
PROCESS_INFORMATION po;
STARTUPINFO
s;
GetStartupInfo (&s);
if(CreateProcess ("c:\s2.exe", NULL, NULL, NULL, false, 0, NULL,
NULL, &s, &po) == FALSE)
{
printf("Error %d starting CC\n",
GetLastError());
exit(-1);
}
HANDLE pipe=CreateNamedPipe (pipe_name, 0x00000003,
FILE_FLAG_FIRST_PIPE_INSTANCE,
PIPE_UNLIMITED_INSTANCES,128, 128, 0,
NULL);
while(WaitNamedPipe(pipe_name, INFINITE)==FALSE) Sleep(300);
HANDLE CC = CreateFile (pipe_name, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
bool fConnected = ConnectNamedPipe(pipe, NULL) ? TRUE :
(GetLastError() ==
ERROR_PIPE_CONNECTED);
if(fConnected) printf("true");
else printf("false");
有一個實際的問題嗎?我確定沒有看到一個。 – 2011-01-28 08:10:21