Click here to change the theme.

This page only provides an overview of this topic but it has links to other sources that  answers questions asked so many times that it is easier to put the links here and then just point here. Be sure to read about Pipes in the Interprocess Communications section of the Platform SDK.

32-bit console programs and DOS programs normally have Standard I/O files that can be used for simple I/O (see Console Handles and stdin, stdout, stderr). A 32-bit Windows program can "redirect" Standard I/O (for a 32-bit console program or DOS program that it invokes by CreateProcess) by opening files and specifying the handles in the call to CreateProcess. Note that Windows GUI (non-console) programs do not have the Standard I/O files available to them unless they first create a console for themselves. See Q105305 - INFO: Calling CRT Output Routines from a GUI Application.

The redirection capability can be used by a GUI program to provide input to a console or DOS program and then to capture the output for display in an edit control or something like that. The "Pipe Handle Inheritance" topic of the Platform SDK documentation describes the functions used and the topic Creating a Child Process with Redirected Input and Output has an example. Also see the following Knowledge Base articles:

The CodeGuru web site has some articles about redirecting Standard I/O. The following articles describe redirecting standard I/O but this is an incomplete list of what is available in the CodeGuru web site.

Using the Command Line

If you want to use the redirection operators (">", "<" or "|") in a command line for a DOS program or DOS command, then you can use CreateProcess to execute the command processor and pass a command with the redirection operators as a parameter. Note that the command processor is for Windows 95 and Cmd.exe for NT.

I am not sure if this works for a 32-bit console program too. Part of what I know says yes and part says no. I should try it sometime.


A pipe is something that originated in the Unix operating system. Imagine a program that writes to a file and then another program that reads from that file. A pipe is something that the operating system creates that works like two files. When a program writes to the pipe the data is provided to another program as if it is input. So the data flows from program to program as if through a pipe.