6

我想复制一个带有偏移量的内存块,可以吗?

这是我到目前为止的代码:

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;
4

2 回答 2

9

目前尚不完全清楚您想要实现什么,但看起来像

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

虽然我怀疑你真的想要

MoveMemory(pointer(NativeUInt(Destination) + 2), @SOURCE[2], SizeOf(SOURCE) - 2)
于 2012-05-20T15:38:52.063 回答
2

要用于Move()复制数组的一部分,请执行以下操作:

Move(SOURCE[Offset], Destination^, SizeOf(SOURCE)-Offset); 
于 2012-05-22T17:55:54.357 回答