Date: Tue, 9 Apr 1996 11:18:34 +0200 (IST) From: Eli Zaretskii 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: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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.