gpt4 book ai didi

delphi - D2007 中的指针算术如何使其工作?

转载 作者:行者123 更新时间:2023-12-03 15:43:49 25 4
gpt4 key购买 nike

在 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 Operator not applicable to this operand type

这段代码有什么问题,我需要进行什么样的类型转换才能使其真正工作?

我在以下(不太复杂的)例程中遇到相同的错误:

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;

最佳答案

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;

关于delphi - D2007 中的指针算术如何使其工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8457314/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com