procedure Join(Main_FileName, Hidden_Filename : string);
var
MainFile : TFileStream;
HiddenFile : TFileStream;
SizeOfFile : Cardinal;
SearchWord : string[10];
begin
MainFile := TFileStream.Create(Main_FileName, fmOpenReadWrite or fmShareDenyWrite);
try
SizeOfFile := MainFile.Size;
HiddenFile := TFileStream.Create(Hidden_Filename, fmOpenRead or fmShareDenyNone);
try
MainFile.Seek(0, soFromEnd);
MainFile.CopyFrom(HiddenFile, 0);
MainFile.Seek(0, soFromEnd);
finally
HiddenFile.Free;
end;
SearchWord := IntToStr(SizeOfFile) + #0;
MainFile.Seek(0, soFromEnd);
MainFile.WriteBuffer(SearchWord, SizeOf(SearchWord));
finally
MainFile.Free;
end;
end;
procedure Split(Main_FileName, NewFromMain_Filename : string);
var
MainFile : TFileStream;
SplitFile : TFileStream;
HelpStr : string[10];
GetSize : integer;
begin
MainFile := TFileStream.create(Main_FileName, fmOpenReadWrite or fmShareDenyWrite);
try
SplitFile := TFileStream.Create(NewFromMain_Filename, fmCreate or fmShareDenyNone);
try
MainFile.Position := MainFile.Size - 11;
MainFile.Read(HelpStr, 10);
GetSize := StrToInt(HelpStr);
MainFile.Position := GetSize;
SplitFile.CopyFrom(MainFile, MainFile.Size-GetSize);
SplitFile.Size := SplitFile.Size - 11;
MainFile.Size := GetSize;
finally
SplitFile.Free;
end;
finally
MainFile.Free;
end;
end;
Beispiel Join :
procedure TForm1.Button1Click(Sender: TObject);
begin
Join('C:\temp.exe', 'C:\temp.txt');
end;
Beispiel Split :
procedure TForm1.Button1Click(Sender: TObject);
begin
Join('C:\temp.exe', 'C:\temp.txt');
end;
Keine Kommentare:
Kommentar veröffentlichen