D2007 中的指针算术如何使其工作?
在 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 错误] IDVirtualDataObject.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;
When compiling Embarcadero VirtualShellTools in Delphi 2007: 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;
I get this error:
[Pascal Error] IDEVirtualDataObject.pas(1023): E2015 Operator not applicable to this operand type
What's the problem with this code and what kind of type-casting do I need to do to actually make it work?
I get the same error on the following (less complex) routine:
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Pointermath 是在 Delphi 2009 中引入的。在 Delphi 2007 中您可以做的最好的事情就是使用
Inc
过程来代替:Pointermath was introduced in Delphi 2009. The best you can do in Delphi 2007 is to use
Inc
procedure instead:您还可以将
PByte
替换为PAnsiChar
。You could also replace
PByte
withPAnsiChar
.