NO_REDIR.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
源码类别:

界面编程

开发平台:

C/C++

  1. #include <stdio.h>
  2. #include <dos.h>
  3. void main (void)
  4.   {
  5.      union REGS inregs, outregs;
  6.      // check the stdin handle first
  7.      inregs.x.ax = 0x4400;
  8.      inregs.x.bx = 0;      // stdin is handle 0
  9.      intdos (&inregs, &outregs);
  10.      if ((outregs.x.dx & 1) && (outregs.x.dx & 128))
  11.        fprintf (stderr, "stdin has not been redirectedn");
  12.      else
  13.        fprintf (stderr, "stdin is redirectedn");                      
  14.      // Now check stdout
  15.      inregs.x.ax = 0x4400;
  16.      inregs.x.bx = 1;      // stdout is handle 1
  17.      intdos (&inregs, &outregs);
  18.      if ((outregs.x.dx & 2) && (outregs.x.dx & 128))
  19.        fprintf (stderr, "stdout has not been redirectedn");
  20.      else
  21.        fprintf (stderr, "stdout is redirectedn");                      
  22.   }