Creo que lo estas enfocando de una manera equivocada JoseFco, para que quieres andar jugando con los datos en un memo cuando ya tienes todos los bytes guardados en un array.
Analicemos el código:
Código Delphi
[-]
var
i,j: Integer;
Str: String;
Buffer: TBuffer;
begin
if OpenDialog1.Execute then
begin
Label1.caption:=OpenDialog1.FileName;
Memo1.Clear;
with TStringList.Create do
try
LoadFromFile(Label1.Caption);
FillChar(Buffer,Sizeof(Buffer),#0);
for i:= 0 to Count - 1 do
Insertar(Strings[i],Buffer);
j:= StrToInt(Label2.caption);
Str:= EmptyStr;
for i:= 0 to j do
begin
Str:= Str + #32 + IntToHex(Buffer[i],2);
if ((i+1) mod 16 = 0) then
begin
Memo1.Lines.Add(Str);
Str:= EmptyStr;
end;
end;
if Str <> EmptyStr then
Memo1.Lines.Add(Str);
finally
Free;
end;
end;
end;
Fíjate que en buffer ya tenemos los bytes tal cual se tienen que mandar al programador, así que cuando hagas la rutina de envío no vayas a coger los datos del memo y convertirlos a bytes, seria hacer el mismo trabajo dos veces.