本文介绍了Delphi指针算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应如何编写此行代码以使其编译

How should this line of code be writed to allow it to compile

MoveMemory(poleFileDescriptorW
         , (oleDataPointer + SizeOf(oleFileDescriptorW) *Index + 4)^
         , SizeOf(oleFileDescriptorW));

尤其是这部分

(oleDataPointer + SizeOf(oleFileDescriptorW)* Index + 4)^

(oleDataPointer + SizeOf(oleFileDescriptorW)*Index + 4)^

我只想将指针移动 SizeOf(oleFileDescriptorW)* Index + 4 个字节

I am just want to shift the pointer by SizeOf(oleFileDescriptorW)*Index + 4 bytes

变量定义为:

pOLEFileDescriptorW : ^FILEDESCRIPTORW;
oleDataPointer : Pointer;

推荐答案

转换为整数类型,进行数学运算并返回.

Cast to an integer type, do the math and cast back.

我通常使用 Cardinal ,但是我认为这不适用于64位编译器.

I usually used Cardinal but I think that doesn't work with a 64 bit compiler.

Pointer(NativeInt(oleDataPointer)+ SizeOf(oleFileDescriptorW)*索引+ 4)

这篇关于Delphi指针算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:13