Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!cg-atla!fredex From: fredex@cg-atla.UUCP (Fred Smith) Newsgroups: comp.sys.ibm.pc Subject: Re: Where oh where does my program reside?? Keywords: the and if then where who what when why how question answer Message-ID: <7808@cg-atla.UUCP> Date: 24 Oct 89 17:41:08 GMT References: <1407@sdcc13.ucsd.edu> Reply-To: fredex@cg-atla.UUCP (Fred Smith) Organization: Agfa Compugraphic Division Lines: 34 In article <1407@sdcc13.ucsd.edu> pa1256@sdcc13.ucsd.edu (Jennifer's Lover) writes: >I have a question regarding how to pull some information out of DOS. > >I want to know, regardless of the current directory, what directory >my program resides in. > >This is what Word-Perfect does when it displays the message: >The system is using C:\WP50. > >Can anyone give me a hand?? > >By the way, I am using Turbo C 2.0 and DOS 3.xx. At MS(PC)-dos beginning at 3.00, the segment which contains the environment of the current program also cotains the full pathname of the program being executed. This is passed thru as argv[0] by Microsoft C. Perhaps Turbo C does the same. NOTE that this feature is available only at DOS 3.0 and later. In previous versions the name or path of the executing program is NOT AVAILABLE. I have always been told that this information lives immediately following the environment in your psp. I just looked at it, however, in Microsoft C/Codeview and in my test case, at least, it actually precedes it. MS C passes a third argument to main, envp, which points to a pointer to the environment string. In the case I just checked, the next word following the pointer to the environment is a pointer to the command head, i.e., the full path of the program executing. Hope this helps you! Fred