Article View: comp.os.msdos.programmer
Article #7377Re: Where's the executable located?
From: Ralf.Brown
Date: Tue, 25 Jun 1991 13:55
Date: Tue, 25 Jun 1991 13:55
22 lines
1773 bytes
1773 bytes
In article <1991Jun24.133431.10280@druid.uucp>, darcy@druid.uucp (D'Arcy J.M. Cain) wrote:
}In <i8Hrm1=@cs.psu.edu> melling@cs.psu.edu (Michael D Mellinger) writes:
}>If my program is in someone's path, how can I tell where it's located
}>so that I can get the supporting files that are needed with it?
}
}This is real easy in DOS. argv[0] is the full pathname of the invoking
}process. I often do something like this:
}[...]
}BTW this only works because COMMAND.COM puts it there. If you call your
No, the kernel's EXEC function puts the program name there. But only in
DOS 3.0 or higher. For DOS 2.x, you'll get an empty string as argv[0]
under the C startups I'm familiar with. If the program is started with
a relative path, you'll get that relative path in argv[0]; if a library
function using a path search is involved, however, the program that DOS
is asked to execute (and whose name is put in argv[0]) of necessity
contains a path even if the original request didn't.
--
{backbone}!cs.cmu.edu!ralf ARPA: RALF@CS.CMU.EDU FIDO: Ralf Brown 1:129/53
BITnet: RALF%CS.CMU.EDU@CARNEGIE AT&Tnet: (412)268-3053 (school) FAX: ask
DISCLAIMER? Did | It isn't what we don't know that gives us trouble, it's
I claim something?| what we know that ain't so. --Will Rogers
Technical Details
Message-ID:
<28674b38@ralf>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!think.com!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!udel!rochester!pt.cs.cmu.edu!ralfShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!think.com!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!udel!rochester!pt.cs.cmu.edu!ralf From: Ralf.Brown@B.GP.CS.CMU.EDU Newsgroups: comp.os.msdos.programmer Subject: Re: Where's the executable located? Message-ID: <28674b38@ralf> Date: 25 Jun 91 13:55:04 GMT Organization: Carnegie Mellon University School of Computer Science Lines: 22