Hi people.
I needed to extract bytes from a file content. So i used following code (using earlrainer function above). I used FileRead and got 2500 bytes into Buffer.
var
aHex : array[0..100] of Char;
S : String;
:
:
FileSeek(iHandle,0,0);
Buffer := PChar(AllocMem(2501));
iRead := FileRead(iHandle, Buffer^, 2500);
S := Buffer[3]+Buffer[4]+Buffer[1]+Buffer[2];
aHex := ' ';
BinToHex(PChar(S),aHex,4);
if StrToIntDef('$'+aHex,0) <> 1024 then
// Something Wrong;
Machine suddenly uses least significant bytes and words first. This is because I read bytes 3 and 4 and after 1 and 2. I need 1024 from $00000400 that is the same thing in different notation. My question is : there´s a easiest way to do this ?
Besides, in other portion I need to compare 50 bytes with a string like this :
S := '';
for iRead := 2048 to 2097 do
S := S + Buffer[iRead];
if S <> 'SOMESTRING' then
// Something wrong too.
Here, I used a FOR loop. Copy(Buffer,2048,50) didn´t work.
Is there a easiest way too to do this ?
Tks in advance.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.