我的代码是这样的
各位看看那里不对了
var
memo1:tmemo;
mybatfile:textfile;
str,substr,insstr:string;
i:integer;
begin
memo1:=tmemo.Create(form1);
memo1.Parent :=form1;
if filesearch('prepare.bat',extractfilepath(application.exename))<>'' then
begin
assignfile(mybatfile,'prepare.bat');
reset(mybatfile);
Deletefile('prepare.bat');
Memo1.Lines.LoadFromFile('prepare.bat');
str:=memo1.Text;
substr:='pengzj';
insstr:='454545';
i:=pos(substr,str);
if i>0 then
begin
delete(str,i,Length(SubStr));
Insert(insstr,str,i);
end;
Memo1.Lines.Clear;
Memo1.Text:=Str;
Deletefile(''''+extractfilepath(application.exename)+'prepare.bat'+'''');
Memo1.Lines.SaveToFile('prepare.bat');
closefile(mybatfile);
end;
end;