Communicating between 16-bit DOS program and 32-bit Windows program

Communicating between 16-bit DOS program and 32-bit Windows program

Post by Trumphurst Lt » Fri, 28 Jul 2000 04:00:00



I need to be able to communicate (in both directions) between a 16-bit
DOS program and a 32-bit Windows program. What methods are available?

I have tried redirecting stdin/stdout/stderr through pipes, but have
had the problems detailed below, so I am looking for another method.

Problems with pipes:

1) Under Windows 2000, sometimes data "sticks" in the pipe (i.e. a read
on the pipe by the DOS program does not return until extra data is
written to the pipe by the Windows program).

2) Under Windows 98, leaving the two programs running (both waiting for
data to be written to the pipes by the other) caused Windows 98 to lock
up. Pressing Ctrl-Alt-Del brings up Task Manager, with a list of
running processes. One of the processes is Task Manager itself, which
is marked as "Not responding"). The only way to get out of this is to
cycle the power switch.

3) Under Windows 95 versions a and c, the pipes don't get connected,
and the DOS program sends its output to (and gets its input from) the
console (which is a hidden window!).

4) Under Windows 95 and 98, if Norton Anti Virus Protect is running, I
also get problem 3.

I have read, and implemented, the 32-bit console program needed in
between the Windows and DOS program, as detailed in KB article Q150956.

I have also read Q190351, which seems to be incorrect when it says
"If the parent process only wishes to redirect one or two standard
handles, specifying GetStdHandle() for the specific handles causes the
child to create the standard handle as it normally would without
redirection. For example, if the parent process only needs to redirect
the standard output and error of the child process, then the hStdInput
member of the STARTUPINFO structure is filled as follows:

   hStdInput = GetStdHandle(STD_INPUT_HANDLE);
"

In my program, doing this (under WIndows 2000 and NT) gets me error 6
("The handle is invalid.") in the intermediate 32-bit console program
when it tries to start the DOS program. The handle returned by
GetStdHandle(STD_OUTPUT_HANDLE) is 65537 (decimal).

--
Nikki Locke, Trumphurst Ltd.      PC & Unix consultancy & programming
http://www.trumphurst.com/