{$I KEYS}

unit INT;
interface

var StartDir :string;

implementation

uses WinProcs;

procedure GetStartDir;
type Atype = array [1..5000] of char;
label 1,2;
var  A :Atype; eseg :word; s    :string; i    :integer;
begin
eseg:={word(ptr(PrefixSeg,$2C)^);} HIWORD(longint(GetDosEnvironment));
A:=Atype(ptr(eseg,0)^);
s:='';
for i:=1 to 5000
do if A[i]=#0
   then if A[i+1]=#1
        then if A[i+2]=#0
             then for i:=i+3 to 5000
                  do begin s:=s+A[i]; if A[i]=#0 then goto 1 end;
1:
for i:=length(s) downto 1
do if s[i] <> '\'
   then delete(s,i,1)
   else goto 2;
2:
StartDir:=s;
end;


begin
GetStartDir;
end.

{ eof INTS }