Tenes razón, disculpas.
Código:
String file_hex(const String aFileName, const int StartingAt, const int Quantity)
{
TFileStream *fs = new TFileStream(aFileName, fmOpenRead);
unsigned char buff;
String str = "";
try {
fs->Seek(StartingAt, soFromBeginning);
for(int i = 0; i < Quantity; i++) {
fs->Read(&buff, 1);
str += IntToHex(buff, 2) + ' ';
}
}
__finally {
delete fs;
}
return str.SetLength(str.Length()-1);
}
Uso:
Código:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Memo1->Text = file_hex("C:\\Windows\\notepad.exe", 95, 20);
}
Ahora a la función se le envían como argumentos, la posición inicial (basada en cero) y la cantidad de elementos a leer a partir de ella.
Saludos