I have been doing a lot of searching and still can't seem to figure out how to fix my issue. I am writing a GUI program (in WinAPI so no MFC please) to communicate with another program (command line based). I am using anonymous pipes since everything is local (but perhaps named pipes would be better?) which then I use CreateProcess(); to run the program I am trying to get the output from.
Now, I just moved from synchronous to asynchronous a few hours ago and am running into a few problems (even though synchronous did not do what I wanted anyway). The first problem is that I am still running into the same problem I had while running synchronous i/o; if I run my "read" (or "write" for that matter) function more than once, the program will freeze. I cannot have this because the purpose of the program is to periodically update to the GUI what the output of the command prompt is.
The second problem, and ultimately more serious is a new one with my asynchronous i/o; it does not read the entire output like my synchronous did. It reads until the program I am reading from sends the return character (or else it is simply coincidental that that is the point where it happens to stop reading). I feel like perhaps I am not fully understanding the capabilities of the OVERLAP, but I'm feeling bogged down by reading so much of the MSDN right now, so perhaps I am overlooking some important aspects of it.
So basically, the code below is the bare minimum of what I am doing. I have tried using various for() and while() loop techniques to try to get through all of the output data, but it seems to be no go. Note that BUFSIZE is defined at 0x1000 which is in fact more than the little test program I wrote for this needs even.
::ReadFile(_hChild_Out_Rd, chBuf, BUFSIZE, &dwRead, &o1);
chBuf[dwRead] = '\0';
::SetDlgItemTextA(global,IDO_WORLDOUT,chBuf);
So does anybody have any ideas?
Thanks so much for your help!
Regards,
Dennis M.