Citat:
Mihajlo Cvetanović: Ups, u pravu si! U trendu pažljivijeg čitanja sledi i jedno pitanje. Dalibore, gde si ti to video da čitanje u parentu ne može zajedno s pisanjem? Šta ako ipak može?
Na:
Creating a Child Process with Redirected Input and Output
Deo:
Code:
void ReadFromPipe(void)
// Read output from the child process's pipe for STDOUT
// and write to the parent process's pipe for STDOUT.
// Stop when there is no more data.
{
DWORD dwRead, dwWritten;
CHAR chBuf[BUFSIZE];
BOOL bSuccess = FALSE;
HANDLE hParentStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
----->// Close the write end of the pipe before reading from the <-----
----->// read end of the pipe, to control child process execution. <-----
----->// The pipe is assumed to have enough buffer space to hold the <-----
----->// data the child process has already written to it. <-----
if (!CloseHandle(g_hChildStd_OUT_Wr))
ErrorExit(TEXT("StdOutWr CloseHandle"));
for (;;)
{
bSuccess = ReadFile( g_hChildStd_OUT_Rd, chBuf, BUFSIZE, &dwRead, NULL);
if( ! bSuccess || dwRead == 0 ) break;
bSuccess = WriteFile(hParentStdOut, chBuf,
dwRead, &dwWritten, NULL);
if (! bSuccess ) break;
}
}
E sad, možda i može istovremeno, ovde kaže da ne, nisam probao.
Razlog sašto ne koristim već gotov source code: jer ne mogu da gubim dane proučavajući ga. Jednostavno uz kompajliran kod ide i DOC u kome ima svih imformacija vezanih za ulazne parametre, koji nije baš mali i zahteva dosta vremena za proučavanje. I nakon toga, mislim da je mnogo brže kreirati gui, koji kreira proces, prosleđuje parametre tom procesu i rezultate predaje korisniku, nego celokupni izvorni kod proučavati, modifikovati, smeštati u dll-ove, a zatim krerati gui aplikaciju koja poziva funkcije iz dll-ova za obradu.
Dalibor Zdravkovic