Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What are the filehandle numbers for devices.

Status
Not open for further replies.

denc4

Programmer
Feb 17, 2005
107
NL
Hi.

Everytime I open a file using INT 21h the system returns
file handle number 5. In plain DOS, AND under Win95.
I came accros some other guy's code and he used file handle
0 (zero) to output text to the screen. Now, I know there are
certain other devices that correspond to certain filehandle
numbers, like stdin and stderr.

Does anybody know what filehandle corresponds to which
device?

I do not want to experiment by writing to, and reading from
filehandle numbers 0 to 4 since I might screw up some file
that the OS uses (like COMMAND.COM or the Windows swap
file or whatever).

Thank You.
 
Default file handles are:

0 STDIN (ie Keyboard - can be redirected)
1 STDOUT (ie Screen - can be redirected)
2 STDERR (ie Error in from Keyboard, out to Screen - can't be redirected)
3 STDAUX (ie COM1)
4 STDPRN (ie LPT1)

Hope this helps
 
guess I misunderstood that guy's code then (wouldn't be the
first time). He must have received input from the user at
that point, and not output to screen.

anyway, thanks for your help. This will open a whole new
chapter for me on how to handle I/O. And better yet, output
to screen even when the user redirects the output to a file,
by using handle 2.

But wait, since DOS provides function 9 INT 21h to output
text, is there a function number to output a dollar
terminated string to stderr? This would save me some string
length calculations of you know what I mean.

thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top