不用分割,直接包装成variant传递,看看下边两个函数
function filetovar(filename:string):variant;
var
stream:tfilestream;
p
ointer;
begin
Stream:=Tfilestream.Create(filename,fmOpenRead);
Stream.Position:=0;
result:= VarArrayCreate([0, Stream.Size - 1], varByte);
p:= VarArrayLock(result);
try
Stream.Position := 0;
Stream.Read(p^, Stream.Size);
finally
VarArrayUnlock(result);
end;
Stream.Free;
end;
procedure vartofile(filevar:variant;filename:string);
var
stream:Tmemorystream;
p
ointer;
begin
Stream:=Tmemorystream.Create;
try
p := VarArrayLock(filevar);
try
Stream.Write(p^, VarArrayHighBound(filevar,1) + 1);
finally
VarArrayUnlock(filevar);
end;
stream.savetofile(filename);
finally
Stream.Free;
end;
end;