[comp.lang.pascal] DOS command line

terran@en.ecn.purdue.edu (The Lord of Fire and Death) (03/20/91)

Does anybody know where the DOS command line is kept in memory and/or
how to find it at run time?  I'm trying to write a TSR that captures and
stores DOS commands and I don't want to have to capture the characters one at a
time.  Any suggestions appreciated.  Thanks in advance.

		Terran Lane
			terran@ecn.purdue.edu

ddavidso@gara.une.oz.au (Dean Davidson) (03/20/91)

In article <1991Mar19.161155.21637@en.ecn.purdue.edu> terran@en.ecn.purdue.edu (The Lord of Fire and Death) writes:
>Does anybody know where the DOS command line is kept in memory and/or
>how to find it at run time?

The following should do the job for you:

--------------------------------------------------------------------

{function to get the command line}
{modified by Dean Davidson from an idea by Trevor Carlson}

type
st = string[128];
pt = ^st;

function cl : st;
{function to get the command line}

var
sp : pt;

begin
  sp := ptr(PrefixSeg,$80);
  cl := sp^;
end;

abcscnuk@csunb.csun.edu (Naoto Kimura (ACM)) (03/20/91)

In article <5694@gara.une.oz.au> ddavidso@gara.UUCP (Dean Davidson) writes:
]In article <1991Mar19.161155.21637@en.ecn.purdue.edu> terran@en.ecn.purdue.edu (The Lord of Fire and Death) writes:
]>Does anybody know where the DOS command line is kept in memory and/or
]>how to find it at run time?
]
]The following should do the job for you:
]
]--------------------------------------------------------------------
]
]{function to get the command line}
]{modified by Dean Davidson from an idea by Trevor Carlson}
]
]type
]st = string[128];
]pt = ^st;
]
]function cl : st;
]{function to get the command line}
]
]var
]sp : pt;
]
]begin
]  sp := ptr(PrefixSeg,$80);
]  cl := sp^;
]end;

One caution with this program...  This only gives the command tail of
the current process (the program accessing the command line that
invoked it).

The original poster was intending to write a TSR that stored command
lines (possibly to be able to recall them later -- much like CED).  I
would suggest getting the book "Undocumented DOS" -- there is a chapter
on command processors which might be of use.  I haven't gotten around to
reading that particular chapter yet, so I can't be sure if it gives the
info the original poster wants, but it should be a start.  For those
who are interested in writing TSR's, it's a must-have !

*******************************************************************
*                                                                 *
*   title:	Undocumented DOS                                  *
*   authors:	Andrew Schulman, Raymond J. Michels, Jim Kyle,    *
*		Tim Paterson, David Maxey, and Ralf Brown         *
*   publisher:	Addison-Wesley Publishing Company                 *
*   cover price: $39.95                                           *
*		 disks w/ software included.                      *
*		 hypertext document of v.4.90 of the Interrupt    *
*		 list!                                            *
*                                                                 *
*******************************************************************

                //-n-\\			 Naoto Kimura
        _____---=======---_____		 (abcscnuk@csuna.csun.edu)
    ====____\   /.. ..\   /____====
  //         ---\__O__/---         \\	Enterprise... Surrender or we'll
  \_\                             /_/	send back your *&^$% tribbles !!