CString str;
assert(hReadPipe);
DWORD BytesRead;
char dest[100];
bool RdLoopDone = false;
while (!RdLoopDone) {
static int a=0;
memset(dest, 0, 100);
assert(ReadFile(hReadPipe, &dest, sizeof(dest), &BytesRead, NULL));
str+=dest;
if (BytesRead < 100) RdLoopDone = true;
if (a > 20) RdLoopDone = true;
a++;//this while loop seems infinit if without any control.
}
CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
CloseHandle(ProcInfo.hProcess);
AfxMessageBox(str);//a big messagebox with long text appear!!
return TRUE;