Registriert seit: 6. Okt 2003
372 Beiträge
|
Re: Zwei Hexwerte tauschen
15. Apr 2004, 14:37
geht glaube ich so:
Delphi-Quellcode:
procedure SwapHexValues(const aFileName, aOutFileName: string; const HexPos1, HexPos2: LongInt);
var
InStream, OutStream: TFileStream;
Hex: Byte;
begin
if HexPos2 < HexPos1 then
SwapHexValues(aFileName, aOutFileName, HexPos2, HexPos1)
else
begin
if not FileExists(aFileName) then exit;
InStream := TFileStream.Create(aFileName, fmOpenRead);
OutStream := TFileStream.Create(aOutFileName, fmCreate);
InStream.Position := 0;
OutStream.CopyFrom(InStream, HexPos1 - SizeOf(Hex));
InStream.Position := HexPos2;
OutStream.CopyFrom(InStream, SizeOf(Hex));
InStream.Position := HexPos1 + SizeOf(Hex);
OutStream.CopyFrom(InStream, HexPos2 - HexPos1 - SizeOf(Hex));
InStream.Position := HexPos1;
OutStream.CopyFrom(InStream, SizeOf(Hex));
InStream.Position := HexPos2 + SizeOf(Hex);
OutStream.CopyFrom(InStream, InStream.Size - HexPos2 - SizeOf(Hex));
OutStream.Free;
InStream.Free;
end;
end;
|
|
Zitat
|