www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/09/04:25:39

Date: Tue, 9 Apr 1996 11:18:34 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: j DOT aldrich6 AT genie DOT com
Cc: djgpp AT delorie DOT com
Subject: Re: Paths and .COM files
In-Reply-To: <199604090252.AA121448338@relay1.geis.com>
Message-Id: <Pine.SUN.3.91.960409110439.24867X-100000@is>
Mime-Version: 1.0

On Tue, 9 Apr 1996 j DOT aldrich6 AT genie DOT com wrote:

> First:  In what order does DOS examine a root filename for valid
> executable extensions?  My experiments would suggest that it looks
> for .COM, followed by .EXE, and finally .BAT, but I'd like some
> confirmation.

That is correct, but for 2 minor points.  First, DOS doesn't search for 
the executable at all, it's COMMAND.COM (or whatever shell that you use) 
that does and submits it to DOS if it finds .com or .exe (DOS cannot 
execute .bat files).  Second, COMMAND.COM searches its list of internal 
commands first, so if you call your program dir.exe it cannot be invoked 
from the COMMAND.COM prompt.

> Second, is it possible for DJGPP to create .COM files?

Actually, the extension isn't important for DOS, it's only important to 
COMMAND.COM.  When the DOS EXEC function (Int 21h/AX=4B00h) is called, 
DOS examines the first two bytes of the file whose name is given to it.  
If these bytes are "MZ" or "ZM", DOS treats it like an .EXE file, 
regardless of the extension; anything else is treated as a .COM program.

> Does anybody here know exactly what would be required to go about
> creating a .COM as opposed to an .EXE?

Why would you need to do that (even if you could, which I think you 
don't)?  For the purpose of reporting the type of the program, it 
suffices to look at the first two bytes of the program file.  There is a 
library function called ``_is_executable'' that does just that.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019