1. int _stdcall TA_InqAcc(AccountMsg * pAccMsg, short TimeOut = 10);入口参数: pAccMsg->AccountNo pAccMsg->CardNo pAccMsg-> StudentCode pAccMsg->IDCard pAccMsg-> StudentCodeTimeOut – 交易超时时间,缺省为10秒出口参数: pAccMsg-从数据库中读出的帐户信息,包括Name、、SexNo、DeptCode、
备 注:pAccMsg->AccountNo、pAccMsg->CardNo、pAccMsg-> StudentCode、pAccMsg->IDCard这四个参数是选择查询条件,必须输入一个typedef struct{ char Name[21]; char SexNo[2]; char DeptCode[19]; unsigned int CardNo; unsigned int AccountNo;
}pAccMsg
我在c#中定义如下:[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AccountMsg
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
public string Name;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
public string SexNo;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 19)]
public string DeptCode; public uint CardNo; public uint AccountNo; }
[System.Runtime.InteropServices.DllImport("C:\\dll\\AIO_API.dll")]
public static extern int TA_InqAcc(ref pAccMsg, Int16 TimeOut);我现在调用成功,
1、如果传一个不存在的AccountNo进去,返回不存在,
2、如果是存在的AccountNo但是提示错误是:无法为//分配的缓冲区太小,不能拷贝,请问传地址怎么传??或者在c#要怎么实现”TA_InqAcc(AccountMsg * pAccMsg, short TimeOut = 10);“
备 注:pAccMsg->AccountNo、pAccMsg->CardNo、pAccMsg-> StudentCode、pAccMsg->IDCard这四个参数是选择查询条件,必须输入一个typedef struct{ char Name[21]; char SexNo[2]; char DeptCode[19]; unsigned int CardNo; unsigned int AccountNo;
}pAccMsg
我在c#中定义如下:[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct AccountMsg
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
public string Name;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 2)]
public string SexNo;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 19)]
public string DeptCode; public uint CardNo; public uint AccountNo; }
[System.Runtime.InteropServices.DllImport("C:\\dll\\AIO_API.dll")]
public static extern int TA_InqAcc(ref pAccMsg, Int16 TimeOut);我现在调用成功,
1、如果传一个不存在的AccountNo进去,返回不存在,
2、如果是存在的AccountNo但是提示错误是:无法为//分配的缓冲区太小,不能拷贝,请问传地址怎么传??或者在c#要怎么实现”TA_InqAcc(AccountMsg * pAccMsg, short TimeOut = 10);“
也可用[In]或者[Out]的Attribute