最近在把一些应用中的项目从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);