Board index » delphi » detecting stdin?

detecting stdin?

greetings

is there any way to detect if data has been piped to a program via stdin?

if i try to check stdin in the usual ways, the program stops waiting from
input from stdin (ie con:).

clues?

 | "The crows seemed to be calling : Byron Jones             |
||  his name, thought Caw"         : Communications Manager  ||
|| - Jack Handey                   : Notre Dame University   ||
 | http://www.nd.edu.au/byronj     : Fremantle, Australia    |

 

Re:detecting stdin?


Quote
Byron Jones wrote:

> greetings

> is there any way to detect if data has been piped to a program via stdin?

Yes. You can use IOCTL (Int 21h, fn 44h):

AX=4400H
BX=file handle (0=stdin)

returns: DX=IOCTL device info

If bit 7 is set, it's a device (stdin). 0 means a disk file.

Andras

Re:detecting stdin?


Quote
byr...@nd.edu.au (Byron Jones) wrote:
>greetings

>is there any way to detect if data has been piped to a program via stdin?

>if i try to check stdin in the usual ways, the program stops waiting from
>input from stdin (ie con:).

>clues?

I/O-control

The files unit at http://users.southeast.net/~rdonais/tpascal.htm has
a function called IsDevice that uses I/O-Control to determine if a
file is assigned to a device.  IsDevice(INPUT) would return true if
input was _not_ redirected, (e.g. associated w/ CON device), or was
redirected from a device such as CON, LPT1, PRN, COM1, etc.  

IsDevice(INPUT) would return false if input was redirected from a DOS
file.  Since DOS uses files to implement pipes, piped input would
appear as being redirected from a file.

    ...red

--
Support the anti-Spam amendment
  Join at http://www.cauce.org/

Other Threads