在Delphi中复制带偏移量的内存
发布时间:2020-12-15 04:30:09 所属栏目:大数据 来源:网络整理
导读:我想复制带偏移的内存块,是否可能? 这是我到目前为止的代码: 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
我想复制带偏移的内存块,是否可能?
这是我到目前为止的代码: 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)^,SizeOf(SOURCE) - 2); end; 解决方法
你想要实现的目标并不完全清楚,但它看起来像
MoveMemory(pointer(NativeUInt(Destination) + 2),@SOURCE[0],SizeOf(SOURCE) - 2) 虽然我怀疑你真的想要 MoveMemory(pointer(NativeUInt(Destination) + 2),@SOURCE[2],SizeOf(SOURCE) - 2) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |