No you need to create one pipe for stdin and stdout. You provide three parameters to the DosCreatePipe, Two HFILE pointers and the size of the pipe. Which one you designate the read handle and the write handle is arbitrary, what get's written to one end of a filehandle can be read at the other, so if you dup stdin with the first handle then your child process will inherit that connected to it's standard inout, so whatevr the parentr process writes to the first filehandle will be read by the standard input of the child, the process for the second file handle is similar, duping it with stdout so that it's inherited as the stdout of the child process. The parent can then read from that file handle anything the child writes to it's standout. Data can travel both ways through each filehandle, however coordinating reading and writing to a signel channel would be complex and error prone, hence the abstraction provides two channels and you use one for reading and one for writing. If you want to connect stderr to a pipe you'll need to create a second pipe, dup stderr to one of the filehandles and use that filehandle tin the parent to read the output of stderr in the child. If you're being tidy you call DosClose on the other filehandle.
So, each call to DosCreatPipe gives you two file handles.
In the parent
1. ***Save your stdin and stdout***
2 Dup one filehandle with stdin, one with stdout, The parent process's stdin is now the filehandle from the pipe. Ditto for stdout. The parents stdinput is connected to the filehandle in the pipe, the child process inherits that filehandle as it's standar output, so that's where it reads from.
3. Call DosExecProg, the child inherits the parents stdin and stdout which are the two filehandles returnd from the pipe call.
4. In the parent
***restore the saved stdin and stdout***
So stdin in the parent is not stdin in the child. The parent writes to the filehandle that's connected to the child processes stdin.
In the child
1 The filehandle that was returned in the DosCreatePipe call in the parent is inherited as stdin, the OS tells the child it's value is 0.
2. The other filehandle returned by the call to DosCreateFile in the parent is inherited by the child as it's standard output. The OS tells the child that it's value is 1.
The child reads from the filehandle with the value 0 and writes to the filehandle with the value 1. The parent reads and writes to the pipe, it's restored it's standard input and standard output to their original values after the call to DosExecProgram.
stdin and sdout are abstractions provided by the operating system. Every process reads from fd0 and writes to fd1, The OS juggles what they actually point to behind the curtain. The parent process changes what it's stdin and stdout point to from fd0 and fd1 to whatever value is returned in the call to DosCreatePipe, the child inherits those values as it's stdin and stdout and the parent resores it's original stdin and stdout. So the parents stdout and stdin aren't coinnected ot the childs, the filehandles returnd from the call to DosCreatePipe are.