读书人

帮忙把这个DLL中公开函数改为C#类型的

发布时间: 2012-06-23 14:52:43 作者: rapoo

帮忙把这个DLL中公开函数改成C#类型的
函数原型:
int RTPC (int TPID,
char* AuthorizedCode,
char* RequestCode,
char* RequestParams,
char* ResponseCode,
int* ResponseBufLen,
char* ResponseParams); safecall;

改成C#类型

[解决办法]

C# code
private int RTPC(int TPID,string AuthorizedCode,string RequestCode,string RequestParams,string ResponseCode,ref int ResponseBufLen,string ResponseParams)
[解决办法]
char*输入的可以用string,输出的用StringBuilder
[解决办法]
这样定义也可以,免除了内存空间的分配:
C# code
public static extern  int RTPC(int TPID, string AuthorizedCode, string RequestCode, string RequestParams, byte[] ResponseCode, ref int ResponseBufLen, byte[] ResponseParams) ;
[解决办法]
探讨
用这个可以,但用IntPtr不行,报内存错误

读书人网 >C#

热点推荐