最近在把一些应用中的项目从D7 升级到 XE5,碰到了不少问题,先是把部分第三方控件改为标准控件,这步比较简单,控件修改完成后在XE5中打开项目,编译,结果是一堆Warning,其中还有几个Error,现把问题记录下来,方便查看。
原代码:
ExitDocimasy(BaseParam.CommProtocol,
PAnsiChar((arAddr[iIndex] as TEdit).Text),
Length(Trim((arAddr[iIndex] as TEdit).Text)),
@arBuf[0], iSendLen);
函数定义:
function ExitDocimasy(ProtocolType: Integer; StrAddr: PAnsiChar; iAddrLen: Integer;
Buf: Pointer; var iDataLen: Integer): Integer; stdcall; external 'PRODLL.dll';
编译提示:
E2010 Incompatible types: 'PAnsiChar' and 'TCaption'
解决方法:
ExitDocimasy(BaseParam.CommProtocol,
PAnsiChar(AnsiString((arAddr[iIndex] as TEdit).Text)),
Length(Trim((arAddr[iIndex] as TEdit).Text)),
@arBuf[0], iSendLen);
博主在将应用程序从Delphi D7更新到XE5的过程中遇到了编译错误。具体表现为在调用函数ExitDocimasy时,由于类型不兼容(E2010 Incompatible types: 'PAnsiChar' and 'TCaption')导致编译警告和错误。解决方法是将TEdit的Text转换为AnsiString后再传递给PAnsiChar。经过修改后的代码成功编译。
509

被折叠的 条评论
为什么被折叠?



