I am using the following code example to redirect the I/O of process created
Creating a Child Process with Redirected Input and Output
I am using WriteFile() function to write the captured output buffer of the process to a .txt file , but I am unable to write large data completely.
The example code uses 4096 bytes as BUFSIZ, for example my process program prints , 1 to 2000, each in a newline to its output buffer, but when I am capturing the buffer and writing it to a text file; I am not getting the complete data.
DWORD desiredAccess = GENERIC_READ | GENERIC_WRITE;
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD dispose = CREATE_ALWAYS;
DWORD attribute = FILE_ATTRIBUTE_NORMAL;
HANDLE write = CreateFile(L"t.txt",desiredAccess,shareMode,NULL,dispose,attribute,NULL);
DWORD bytesRead;
WriteFile(write, chBuf, dwRead, &bytesRead, NULL);
Kindly suggest some possible way around for reading and storing large outputs.