110,538
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 读卡
/// </summary>
///参数:int ReadCard(char *room, char *gate,char *stime, char *guestname, char *guestid, char *track1, char *track2, long *cardno, int *st, int *Breakfast);
///room [out]:字符串指针,接收返回的房号,建议10字节。
///gate [out]:字符串指针,接收返回的授权公共通道,可以为NULL。
///Guestname [out]:字符串指针,接收返回的客人姓名,可以为NULL。
///Guestid [out]:字符串指针,接收返回的客人ID,可以为NULL。
///track1 [out]:接收磁卡第1轨数据,可以为NULL。
///track2 [out]:接收磁卡第2轨数据,可以为NULL。
///Cardno [out]:长整形指针,接收返回的卡号,可以为NULL。
///St [out]:整形指针,接收返回的卡状态,1-正常使用,3-正常注销,4-遗失注销,5-损毁注销,6-自动注销。可以为NULL。
///Breakfast [in]: 整形指针,接收早餐券数量。可以为NULL。
//[DllImport("MainDll.dll", CharSet = CharSet.Ansi)]
// public static extern int ReadCard(ref string room, ref string gate, ref string stime, ref string guestname, ref string guestid, ref string track1, ref string track2, ref int cardno, ref int st);
[DllImport("MainDll.dll", CharSet = CharSet.Ansi)]
public static extern int ReadCard(ref IntPtr room, ref IntPtr gate, ref IntPtr stime, ref IntPtr guestname, ref IntPtr guestid, ref IntPtr track1, ref IntPtr track2, ref IntPtr cardno, ref IntPtr st);
IntPtr room = IntPtr.Zero;
IntPtr gate = IntPtr.Zero;
IntPtr stime = IntPtr.Zero;
IntPtr guestName = IntPtr.Zero;
IntPtr guesiID = IntPtr.Zero;
IntPtr track1 = IntPtr.Zero;
IntPtr track2 = IntPtr.Zero;
IntPtr cardNo = IntPtr.Zero;
IntPtr st = IntPtr.Zero;
int num = BLL.BLLADELCard.Init("");
int result = BLL.BLLADELCard.ReadCard(ref room, ref gate, ref stime, ref guestName, ref guesiID, ref track1, ref track2, ref cardNo, ref st);
string strRoom = Marshal.PtrToStringAnsi(room);
[DllImport("MainDll.dll", CharSet = CharSet.Unicode)]
string string strRoom = Marshal.PtrToStringUni(room);
[DllImport("MainDll.dll", CharSet = CharSet.Auto)]
Marshal.PtrToStringAuto
[DllImport("MainDll.dll", CharSet = CharSet.Unicode)]
string string strRoom = Marshal.PtrToStringAnsi(room);