; Jerry Coffin

 Q. How can I tell if my program has been redirected to or from a file?

You use DOS function 44, subfunction 0:

IS_DEVICE      EQU    0080h
IS_FASTCONSOLE EQU    0010h
IS_CONSOUT     EQU    0002h
IS_CONSIN      EQU    0001h

isconsol proc
;
; call with handle of file to test in BX
;
; Destroys DX
;
; On return, zero flag idicates status:
;	set = redirected
; clear = console
;
    mov ax,4400h
    mov bx,handle
    int 21h
;
; the test for a device must be done separately because the states
; of the other bits are only meaningful if it is a device.
;
    test dx,IS_DEVICE
    jz  done
    test dx,IS_CONSOUT | IS_CONSIN | IS_FASTCONSOLE
done:
    ret
isconsol endp
