sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = true; sa.lpSecurityDescriptor = NULL; if (!CreatePipe(&readHandle, &writeHandle, &sa, 0)) // Report error // These next four lines are things I've tried to get it to work better, none of them have changed anything: SetNamedPipeHandleState(readHandle, PIPE_READMODE_BYTE, NULL, NULL); SetNamedPipeHandleState(writeHandle, PIPE_READMODE_BYTE, NULL, NULL); int fileno = _open_osfhandle((long)writeHandle, 0); _setmode(fileno, O_BINARY); // Then I prepare and run the app si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; si.hStdOutput = writeHandle; si.hStdError = writeHandle; if (!CreateProcessA(pathnameToExeOnly, fullCmdLine, NULL, NULL, true, 0, NULL, NULL, &si, &pi)) // Report error // Then I enter a loop while (1) { if (!PeekNamedPipe(readHandle, buffer, sizeof(buffer), &lnBytesRead, &lnTotalBytes, &lnBytesLeft)) // Report error, break if (lnBytesRead) { if (!ReadFile(readHandle, buffer, sizeof(buffer) - 1, &lnBytesRead, NULL)) // Report error, break // Here I process the read data block } } // Clean house CloseHandle(pi.hThread); CloseHandle(pi.hProcess); CloseHandle(readHandle); CloseHandle(writeHandle);As I say, it works properly, but PeekNamedPipe() does not return any bytes until a large block is available. I'd like to have it transferring in binary byte mode.