You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace demo.ExternalDevices
|
|
{
|
|
public enum EM_READCARD
|
|
{
|
|
OPEN_FAILED,
|
|
IDENTIFY_FAILED,
|
|
READ_FAILED,
|
|
READ_OK
|
|
}
|
|
class JingLun
|
|
{
|
|
[DllImport(@"jinglun_dll\Sdtapi.dll")]
|
|
private static extern int InitComm(int iPort);
|
|
[DllImport(@"jinglun_dll\Sdtapi.dll")]
|
|
private static extern int Authenticate();
|
|
[DllImport(@"jinglun_dll\Sdtapi.dll")]
|
|
private static extern int ReadBaseInfos(StringBuilder Name, StringBuilder Gender, StringBuilder Folk,
|
|
StringBuilder BirthDay, StringBuilder Code, StringBuilder Address,
|
|
StringBuilder Agency, StringBuilder ExpireStart, StringBuilder ExpireEnd);
|
|
[DllImport(@"jinglun_dll\Sdtapi.dll")]
|
|
private static extern int CloseComm();
|
|
[DllImport(@"jinglun_dll\Sdtapi.dll")]
|
|
private static extern int ReadBaseMsg(byte[] pMsg, ref int len);
|
|
[DllImport(@"jinglun_dll\Sdtapi.dll")]
|
|
private static extern int ReadBaseMsgW(byte[] pMsg, ref int len);
|
|
|
|
|
|
public static EM_READCARD ReadCard(StringBuilder Name, StringBuilder Code)
|
|
{
|
|
//Name = new StringBuilder(31);
|
|
StringBuilder Gender = new StringBuilder(3);
|
|
StringBuilder Folk = new StringBuilder(10);
|
|
StringBuilder BirthDay = new StringBuilder(9);
|
|
//Code = new StringBuilder(19);
|
|
StringBuilder Address = new StringBuilder(71);
|
|
StringBuilder Agency = new StringBuilder(31);
|
|
StringBuilder ExpireStart = new StringBuilder(9);
|
|
StringBuilder ExpireEnd = new StringBuilder(9);
|
|
byte[] pMsg = new byte[256];
|
|
int len = 0;
|
|
string[] temp;
|
|
string[] baseinfo = new string[9];
|
|
char[] param = { '\0' };
|
|
|
|
//打开端口
|
|
int intOpenRet = InitComm(1001);
|
|
if (intOpenRet != 1)
|
|
{
|
|
return EM_READCARD.OPEN_FAILED;
|
|
}
|
|
|
|
//卡认证
|
|
int intReadRet = Authenticate();
|
|
if (intReadRet != 1)
|
|
{
|
|
CloseComm();
|
|
return EM_READCARD.IDENTIFY_FAILED;
|
|
}
|
|
|
|
int intReadBaseInfosRet = ReadBaseInfos(Name, Gender, Folk, BirthDay, Code, Address, Agency, ExpireStart, ExpireEnd);
|
|
if (intReadBaseInfosRet != 1)
|
|
{
|
|
CloseComm();
|
|
return EM_READCARD.READ_FAILED;
|
|
}
|
|
return EM_READCARD.READ_OK;
|
|
}
|
|
}
|
|
}
|