Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi pointer arithmetic

Tags:

delphi

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

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

Particularly this part

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

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

Variables are defined as:

pOLEFileDescriptorW : ^FILEDESCRIPTORW;
oleDataPointer : Pointer;
like image 368
v00d00 Avatar asked Nov 29 '10 12:11

v00d00


1 Answers

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

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

Pointer(NativeInt(oleDataPointer) + SizeOf(oleFileDescriptorW)*Index + 4)

like image 160
CodesInChaos Avatar answered Sep 20 '22 19:09

CodesInChaos