C# 调用DELPHI接口函数无法通过

DELPHI接口:function writecard(s:string):integer;stdcall;

C#接口声明:
[DllImport(LfV15Dll,CharSet=CharSet.Ansi,CallingConvention =CallingConvention.StdCall)]
public static extern int writecard( string cardInfo);

在调用接口时,一直显示“数据结构错误”。

请教各位大神:
DELPHI string为内置数据结构,是否跨平台无法调用?应如何修改?

delphi的代码能修改么?delphi的string和C#的string不兼容,用PChar ^代替,这和C#的StringBuilder兼容。

string 类型根据编译参数的不同,所代表的含义也不同,或者说根据 Delphi 版本的不同,所代表的含义也不同,
在 Ansi 版本(Delphi 2009 之前)中,string 就代表 AnsiString,而在 Unicode 版本(Delphi 2009 之后)中,就代表 UnicodeString。

把delphi中string变量用pchar就可以了