Registriert seit: 20. Jun 2004
Ort: Berlin
89 Beiträge
Delphi 7 Enterprise
|
Re: Datei Binär auslesen
6. Feb 2005, 19:30
Bei mir läuft es auch, ich hab das ganze mal für binär umgeändert...
Delphi-Quellcode:
function BuffToBin(ByteArray: TMyByteArray): string;
var
i: Integer;
s,foo: string;
const
bin : array[$0..$F] of string = ('0000','0001','0010','0011','0100','0101','0110','0111','1000','1001','1010','1011','1100','1101','1110','1111');
begin
SetLength(foo, Length(ByteArray) * 9);
for i := 0 to High(ByteArray) do
begin
s := bin[((ByteArray[i] and $F0) shr 4)] + Bin[(ByteArray[i] and $0F)]+' ';
Move(s[1], foo[i * 9 + 1], 9);
end;
Result := foo;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
fs: TFileStream;
Buffer: TMyByteArray;
BytesRead: Longint;
s: string;
i: Int64;
begin
i := 0;
SetLength(Buffer, BUFFERSIZE);
fs := TFileStream.Create('c:\boot.ini',fmOpenRead);
SetLength(s, fs.size * 9);
try
repeat
BytesRead := fs.Read(Buffer[0], BUFFERSIZE);
Move(BuffToBin(Buffer)[1], s[i * (9 * BUFFERSIZE) + 1],9 * BytesRead);
Inc(i);
until BytesRead < BUFFERSIZE;
Memo1.Text := s;
finally
FreeAndNil(fs);
end;
end;
Thomas H.
|
|
Zitat
|