harris@ecsvax.UUCP (Mark Harris) (07/22/89)
I am writing a program which needs to know the path through which it was loaded (rather than the current working directory). DOS 3.x puts this path in the environment, but DOS 2.x doesn't. Is there a reasonably simple way to find this path in DOS 2.x? -- Mark Harris mail:harris@ecsvax(UUCP/BITNET) Department of Mathematical Sciences Appalachian State University Boone, NC 28608 (704) 262-3050 office, 264-6906 home
madd@bu-cs.BU.EDU (Jim Frost) (08/08/89)
In article <7207@ecsvax.UUCP> harris@ecsvax.UUCP (Mark Harris) writes: |I am writing a program which needs to know the path through which |it was loaded (rather than the current working directory). DOS |3.x puts this path in the environment, but DOS 2.x doesn't. Is |there a reasonably simple way to find this path in DOS 2.x? No. One way to do it is to compile the name of the program in and run a path search until you find it. Unfortunately if you rename the program or if you give an absolute path (either to override the path or to get to an executable which is not on the path) you will not be able to find the executable. jim frost software tool & die madd@std.com
jrv@demon.siemens.com (James R Vallino) (08/08/89)
In article <36047@bu-cs.BU.EDU> madd@bu-it.bu.edu (Jim Frost) writes: >In article <7207@ecsvax.UUCP> harris@ecsvax.UUCP (Mark Harris) writes: >|I am writing a program which needs to know the path through which >|it was loaded (rather than the current working directory). DOS >|3.x puts this path in the environment, but DOS 2.x doesn't. Is >|there a reasonably simple way to find this path in DOS 2.x? > >No. One way to do it is to compile the name of the program in and run >a path search until you find it. Unfortunately if you rename the >program this is a problem >or if you give an absolute path (either to override the path >or to get to an executable which is not on the path) not a problem because if I remember correctly back to the dark ages DOS 2.x would not let you specify an absolute path to an executable. >you will not be >able to find the executable. Jim Vallino Siemens Corporate Research, Princeton, NJ jrv@demon.siemens.com princeton!siemens!demon!jrv (609) 734-3331
dkelly@npiatl.UUCP (Dwight Kelly) (08/11/89)
In article <13343@siemens.siemens.com> jrv@demon.siemens.com (James R Vallino) writes: >In article <36047@bu-cs.BU.EDU> madd@bu-it.bu.edu (Jim Frost) writes: >>In article <7207@ecsvax.UUCP> harris@ecsvax.UUCP (Mark Harris) writes: >>|I am writing a program which needs to know the path through which >>|it was loaded (rather than the current working directory). DOS >>|3.x puts this path in the environment, but DOS 2.x doesn't. Is >>|there a reasonably simple way to find this path in DOS 2.x? >> >>No. One way to do it is to compile the name of the program in and run >>a path search until you find it. Unfortunately if you rename the >>program > > this is a problem > >>or if you give an absolute path (either to override the path >>or to get to an executable which is not on the path) > > not a problem because if I remember correctly back to the dark ages DOS >2.x would not let you specify an absolute path to an executable. > Generally I do the following: 1) if Dos3.x, get the path out of argv[0] 2) if Dos2.x, do each of the following in order until you find the program. a) look in the current directory. b) following the PATH, looking for the program c) choose one of the following: c1) ask the user for the path c2) scan all directories for the program c3) store a configuration file somewhere that contains the path c4) dump core -- Dwight Kelly UUCP: gatech!npiatl!dkelly Director R&D AT&T: (404) 962-7220 Network Publications, Inc 2 Pamplin Drive Lawrenceville, GA 30245 Publisher of "The Real Estate Book" nationwide!