var afile,bfile: file; filebuf: array of char; i, filelen: integer;
begin assignfile(afile, '文件路径'); reset(afile); filelen:= filesize(afile); setlength(filebuf, filelen); blockread(afile, filebuf, filelen); closefile(afile); i:=0; while i < filelen do begin if filebuf[i]='g' then begin inc(i); if filebuf[i]='a' then begin inc(i); if filebuf[i]='m' then begin inc(i); if filebuf[i]='e' then begin break; end else continue; end else continue; end else continue; end; inc(i); end; copy(filebuf,i-3,filelen); assignfile(bfile, '文件路径'); rewrite(bfile); blockwrite(bfile, filebuf, length(filebuf)); closefile(bfile); end;
CreateFileMapping,MapViewOfFile
afile,bfile: file;
filebuf: array of char;
i, filelen: integer;
begin
assignfile(afile, '文件路径');
reset(afile);
filelen:= filesize(afile);
setlength(filebuf, filelen);
blockread(afile, filebuf, filelen);
closefile(afile);
i:=0;
while i < filelen do
begin
if filebuf[i]='g' then
begin
inc(i);
if filebuf[i]='a' then
begin
inc(i);
if filebuf[i]='m' then
begin
inc(i);
if filebuf[i]='e' then
begin
break;
end else continue;
end else continue;
end else continue;
end;
inc(i);
end;
copy(filebuf,i-3,filelen);
assignfile(bfile, '文件路径');
rewrite(bfile);
blockwrite(bfile, filebuf, length(filebuf));
closefile(bfile);
end;