D2007中的指针算法如何使其工作?

Joh*_*ica 3 delphi delphi-2007

在Delphi 2007中编译Embarcadero VirtualShellTools时:http://embtvstools.svn.sourceforge.net/

function TShellIDList.InternalChildPIDL(Index: integer): PItemIDList;
{ Remember PIDLCount does not count index [0] where the Absolute Parent is     }
begin
  if Assigned(FCIDA) and (Index > -1) and (Index < PIDLCount) then
    Result := PItemIDList( PByte(FCIDA) 
                         + PDWORD(PByte(@FCIDA^.aoffset)
                                  +sizeof(FCIDA^.aoffset[0])*(1+Index))^)
  else
    Result := nil
end;
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

[Pascal Error] IDEVirtualDataObject.pas(1023):E2015运算符不适用于此操作数类型

这段代码有什么问题,我需要做什么样的类型转换才能真正实现它?

我在以下(不太复杂)的例程中得到了同样的错误:

function TShellIDList.InternalParentPIDL: PItemIDList;
{ Remember PIDLCount does not count index [0] where the Absolute Parent is     }
begin
  if Assigned(FCIDA) then
      Result :=  PItemIDList( PByte(FCIDA) + FCIDA^.aoffset[0])
  else
    Result := nil
end;
Run Code Online (Sandbox Code Playgroud)

klu*_*udg 6

Pointermath是在Delphi 2009中引入的.您在Delphi 2007中可以做的最好的事情就是使用Inc过程:

function TShellIDList.InternalChildPIDL(Index: integer): PItemIDList;
{ Remember PIDLCount does not count index [0] where the Absolute Parent is     }
var
  Tmp, Tmp2: PByte;

begin
  if Assigned(FCIDA) and (Index > -1) and (Index < PIDLCount) then begin
    Tmp2:= PByte(@FCIDA^.aoffset);
    Inc(Tmp2, sizeof(FCIDA^.aoffset[0])*(1+Index));
    Tmp:= PByte(FCIDA);
    Inc(Tmp, PDWORD(Tmp2)^);
    Result := PItemIDList(Tmp);
  end
  else
    Result := nil
end;
Run Code Online (Sandbox Code Playgroud)