tags:

views:

62

answers:

2

Hello,

I am trying to write a GUI program for a command line program in Win32 using WinAPI (so please no MFC). In my current attempt, I am creating an input pipe and an output pipe to read/write data. However, my problem comes in when I attempt to continuously read from a program or to simply write after a single read due to the way I have to "CloseHandle();"'s. Is there any good way around this that anyone can recommend? I need to keep the sub-process open the entire time I am reading from/writing to it. Is there perhaps a better way over using CreatePipe(); and CreateProcess(); to do this?

Regards,
Dennis M.

+1  A: 

You need to use Asynchronous I/O.

Billy ONeal
That works great except I still can't read from the pipe more than once otherwise the program freezes. Any ideas on that?
RageD
@Dennis: Why not? When the process writes into the pipe you should be signaled, and when you're done you should unsignal the pipe so you get signaled again. You can open up System.Diagnostics.Process on the .NET framework in Reflector to see how they do it there.
Billy ONeal
+1  A: 

I'm not sure I completely understand your problem.

I assume you've seen this MSDN article (http://msdn.microsoft.com/en-us/library/ms682499(VS.85).aspx) and have code similar to it?

I found it easier to use overlapped I/O and I/O completion ports to handle the pipes, so I wrote a wrapper to create the pipes correctly (http://www.lenholgate.com/archives/000762.html).

Len Holgate