Copy memory with offset in Delphi

I want to copy a memory block with an offset, is this possible?

This is the code that I still have:

const SOURCE: array [0..5] of Byte = ($47, $49, $46, $38, $39, $61); var Destination: Pointer; begin // This is a full copy Move(SOURCE, Destination^, SizeOf(SOURCE)); // If i want to copy from the third byte, is it possible? // I imagine the code should be, but it cannot be compiled. Move(Slice(SOURCE^, {Offset=}2)^, Destination^, SizeOf(SOURCE) - 2); end; 
+6
source share
2 answers

It’s not clear what you want to achieve, but it looks like

 MoveMemory(pointer(NativeUInt(Destination) + 2), @SOURCE[0], SizeOf(SOURCE) - 2) 

although I suspect you really want

 MoveMemory(pointer(NativeUInt(Destination) + 2), @SOURCE[2], SizeOf(SOURCE) - 2) 
+9
source

To use Move() to copy part of an array, do the following:

 Move(SOURCE[Offset], Destination^, SizeOf(SOURCE)-Offset); 
+2
source

Source: https://habr.com/ru/post/916202/


All Articles