Compatibility: 2.0+
Expects: AH    46H
BX    destination file handle (must already exist)
CX    source file handle (must already exist)
Returns: AX    error code if CF is set to CY
Info: Forces a file handle to refer to a different file or device.  The
file handle in CX (the source) is closed (if currently open) and
then made to become a duplicate of the handle in BX (the

In other words, both CX and BX will refer to the same physical
file or device.  All accesses of the CX-handle file will go to or
come from the BX-handle file.

Use this function to redirect Standard I/O.  For example:

  Open a text file for output and obtain its handle (e.g.,

  Set BX=0005H, CX=0001H and call Fn 46H.  Note:  Handle 0001H
is the pre-defined handle of the "standard output device".

  Use Fn 3eH Close File to close handle 05H if you wish.

  All subsequent output to the "standard output" by any process
(the current process or any spawns), including outputs via
any DOS Character I/O function and any writes to file handle
0001H via DOS Fn 40H, will go to the text file.

  When you exit, the pre-defined file handles are reset to the
normal devices (e.g., handle 0001H is reset to "CON").

- -

DOS Fn 46H: Redirect a Handle