{ ToBinStr
convertion d'un buffer vers representation binaire
params :
Buffer [i] constante non typée
BufferSize [i] taille du buffer en octets
returns :
String, chaine de caractere representant buffer en binaire.
}
function ToBinStr(const Buffer; const BufferSize : integer) : string;
var
pB : ^byte;
pR : PChar;
N : integer;
const
BC : array[boolean] of char = '01';
begin
pB := @Buffer;
inc(pB, BufferSize-1);
SetLength(result, BufferSize shl 3);
pR := PChar(Result);
for N := 0 to BufferSize-1 do
begin
pR[0] := BC[ (pB^ and $80) = $80 ];
pR[1] := BC[ (pB^ and $40) = $40 ];
pR[2] := BC[ (pB^ and $20) = $20 ];
pR[3] := BC[ (pB^ and $10) = $10 ];
pR[4] := BC[ (pB^ and $08) = $08 ];
pR[5] := BC[ (pB^ and $04) = $04 ];
pR[6] := BC[ (pB^ and $02) = $02 ];
pR[7] := BC[ (pB^ and $01) = $01 ];
dec(pB);
inc(pR,8);
end;
end;