Reputation: 501
I want to take 4 Bytes from
Source : Array[0..500] of Byte;
where
c : integer; // Start Point
to
v : LongInt;
but
Move(Source[c], v, 4);
gives me only 1 Byte back. Where is my fault?
Thanks again.
Upvotes: 1
Views: 5063
Reputation: 17203
I doubt move is failing:
Try this code:
procedure TForm1.Button1Click(Sender: TObject);
var
source: array[0..500] of Byte;
C: Integer;
V: LongInt;
begin
source[0] := $55;
source[1] := $55;
source[2] := $55;
source[3] := $55;
C := 0;
Move(Source[C], V, SizeOf(V));
ShowMessage(IntToStr(V));
end;
You will see the number 1431655765 ($55555555) in the message.
Upvotes: 2
Reputation: 116110
This source works perfectly fine. It may however look like it returns only a byte if only the first byte (the one at index c
) contains a value other than 0
.
This alternative, already suggested by Sertac Akyuz, works fine as well:
v := PLongInt(@Source[c])^;
Upvotes: 5