在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;
我收到此错误:
[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;
答案 0 :(得分: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;
答案 1 :(得分:3)
您也可以将PByte
替换为PAnsiChar
。