Procedure TFM_Main.DecomposeFile(path:string); //分解文件
var
f:textfile;
info:FILE_INFO;
i,j:integer;
buf:array[0..4096] of byte;
s:integer;
count,b:integer;
dir,strtmp:string;
FilebottomInfo:array[0..100] of byte;
FileLen:Longint;
begin
//dir:=GetTempDirectory;
strtmp:=' ';
for j:=0 to 100 do
FilebottomInfo[j]:=0;
dir:=path;
try
fstream1:=tfilestream.Create(paramstr(0),fmShareDenyWrite);
filelen:=GetFileSize(application.ExeName);
fstream1.Seek(filelen-100,soFromBeginning);
fstream1.Read(FilebottomInfo,sizeof(filebottominfo));
try
j:=0;
while (j<10)do
begin
if (FilebottomInfo[j]>47) and (FilebottomInfo[j]<121) then
strtmp[j+1]:=chr(FilebottomInfo[j])
else
strtmp[j+1]:=chr(32);
j:=j+1;
end;
filelen:=strtoint(trim(strtmp));
except
exit;
end;
fstream1.Seek(filelen,soFromBeginning);
while fstream1.Position<>fstream1.Size-100 do
begin
fstream1.Read(info,sizeof(info));
count:=0;
assignfile(f,dir+info.filename);
rewrite(f);
closefile(f);
fstream2:=tfilestream.Create(dir+info.filename,fmopenwrite);
fstream2.Size:=0;
i:=info.len div sizeof(buf);
for b:=1 to i do
begin
s:=fstream1.Read(buf,sizeof(buf));
fstream2.Write(buf,s);
inc(count,s);
end;
s:=fstream1.Read(buf,info.len-count);
fstream2.Write(buf,s);
fstream2.Free;
end;
finally
fstream1.Free;
end;
end;