下面的代码纯属凭空捏造,随手写的,可能包含错误,自己对照修改吧.
var
i:integer;
buf:tstrings;
Temp:string;
found:boolean;
begin
buf:=tstringlist.create;
found:=false;
buf.loadfromfile('c:/autoexec.bat');
for i:=0 to buf.count-1 do
begin
Temp:=Copy(Trimleft(buf.strings),0,3);
if (copy(temp,0,2)=';;') or (uppercase(Temp)='REM') then
continue;
if pos('c:/forxpro25',buf.strings)>0 then
begin
found:=true;
break;
end;
end;
if not found then
begin
buf.add('path=%path%,c:/foxpro25');
buf.Savetofile('c:/autoexec.bat');
end;
buf.free;
end;