Delphi5 dll在Delphi 2009调用出问题
用Delphi5写的一个内部测试用的DLL如下:
function GetID(A:string;B:Integer;C:Integer): string; stdcall;
export GetID;
如果直接用Delphi5来调用,没问题,但给Delphi2009调用的时候,传入GetID('100',0,0),结果log表明,'100'变成'1'了
改成PChar后问题依然存在,什么原因呢?
[解决办法]
D2009开始字符串默认为Unicode
[解决办法]
Delphi2009调用时修改函数说明为下面形式就应该可以用了:
function GetID(A:AnsiString;B:Integer;C:Integer): AnsiString; stdcall;