Shell process’ standard output reading in Visual Basic 6

pollingprocessstdoutvb6

First, let me say that I'm not a Visual Basic 6 expert…

My need is to:

  • launch from a VB6 client code an exeternal .exe file
  • wait for the process to finish and – during its execution – read the messages coming from its standard output "on the fly" (so that I can print it on a text-filed widget or similars).

I'm wondering if it is even possible to do that in VB6…after a long search on the Internet I didn't come up with anything. Found a lot of examples of how to use the Shell function, but it seems to force me to read the stdout all at once when the process' execution is over, but I want to poll the process for "fresh" messages as they become available.

Any code snippets/suggestions/references are really appreciated.

Thanks in advance!

Best Answer

Use CreatePipe() to create an anonymous pipe that you can pass to CreateProcess(). You can then read from this pipe as required (either using polling or overlapped/async I/O.

This should give you enough info to find a good example.

Related Topic