捆绑:
var
ms1, ms2: TMemoryStream;
Program2Size: Integer;
begin
ms1 := TMemoryStream.Create;
ms2 := TMemoryStream.Create;
try
ms1.LoadFromFile('Program1.exe');
ms2.LoadFromFile('Program2.exe');
ms1.Seek(0, soFromEnd);
ms1.CopyFrom(ms2, ms2.Size);
Program2Size := ms2.Size;
ms1.Write(Program2Size, 4);
ms1.SaveToFile('Program12.exe');
finally
ms1.Free;
ms2.Free;
end;
end;
释放:
var
fs: TFileStream;
ms: TMemoryStream;
Program2Size: Integer;
begin
fs := TFileStream.Create(ParamStr(0), fmOpenRead or fmShareDenyNone);
ms := TMemoryStream.Create;
try
fs.Seek(-4, soFromEnd);
fs.Read(Program2Size, 4);
fs.Seek(-4-Program2Size, soFromEnd);
ms.CopyFrom(fs, Program2Size);
ms.SaveToFile('Program2.exe');
finally
fs.Free;
ms.Free;
end;
end;