VB6 - ShellPipe "Shell with I/O Redirection" control-VBForums
Results 1 to 10 of 10

Thread: VB6 - ShellPipe "Shell with I/O Redirection" control

Threaded View

  1. #1

    Thread Starter
    Join Date
    Feb 2006

    VB6 - ShellPipe "Shell with I/O Redirection" control

    Note: Please see new attachment posted a few replies down!


    ShellPipe is a VB6 UserControl that can be used to "shell" (run) a child process that uses the standard I/O streams, redirecting the child's streams to the anonymous pipes created in the parent process.

    Much of this can be accomplished using the Scripting Runtime. However this has many limitations such as synchronous I/O operations that are not compatible with the event-driven model of the typical VB6 program.

    This UserControl wraps up a lot of the Win32 API calls you might do this with yourself into a "black box" easily dropped into Projects.

    Sort of like Winsock

    So the ShellPipe control has an object model somewhat like the standard Winsock control.

    Once the parent runs the child successfully (optionally passing a command line) the parent can write to the child's StdIn stream. Child events such as StdOut stream output and termination raise events in the parent.

    Minor streamlining

    Both StdOut and StdErr output from the child take one combined path back to the parent. You could easily break this out and use a second DataArrival Event or an additional parameter identifying the source.

    Output polling is done using a Timer control to support Win9x, since Win9x cannot do overlapped I/O.

    Different view of client/server

    One way to look at the relationship is to consider the parent to be a "client" and the child a "server." This is more like the COM and RPC model of communication than what we think of with TCP/IP.

    You can easily use a control array of ShellPipe controls to allow the parent to run multiple children.


    Here I have a simple child program (server) which uses the Scripting Runtime for StdIO, since it doesn't need to do any async processing. This server accepts file directory lookup requests and returns a directory listing reply.

    The parent program (client) uses a ShellPipe control to run the server. Then it awaits user input for directory lookups, formats/sends these requests to the server, and displays returned response data. While this goes on it runs a Timer-driven visual "heartbeat" to demonstrate the non-blocking nature of ShellPipe.
    Last edited by dilettante; Aug 18th, 2012 at 07:49 AM. Reason: deleted original attachment, see new one below

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width