62,046
社区成员
发帖
与我相关
我的任务
分享
[DllImport("termb.dll")]
public static extern int InitComm(int Port);
[DllImport("termb.dll")]
public static extern int CloseComm();
[DllImport("termb.dll")]
public static extern int Authenticate();
[DllImport("termb.dll")]
public static extern int Read_Content(int Aetive);
[DllImport("termb.dll")]
public static extern int GetPeopleName(byte[] strTmp, int strLen);
[DllImport("termb.dll")]
public static extern int GetPeopleSex(byte[] strTmp, int strLen);
iRet = C_GTICR100.InitComm(Port);
public static bool AuthenticateCard()
{
int iRet;
CleanErrMsg();
iRet = C_GTICR100.Authenticate();
if (iRet == 1)
return true;
else
{
SetErrMsg("未放卡或卡放置不正确!如果已经正确放置,请先把卡拿开,然后再重新正确放置卡!");
return false;
}
}
public static bool ReadCard(int Active)
{
int iRet;
CleanErrMsg();
iRet = C_GTICR100.Read_Content(Active);
if (iRet == 1)
return true;
else
{
switch (iRet)
{
case 0:
SetErrMsg("读卡错误!请拿走卡然后重新放置!");
break;
case -1:
SetErrMsg("相片解码错误!");
break;
case -2:
SetErrMsg("wlt文件后缀错误!");
break;
case -3:
SetErrMsg("wlt文件打开错误!");
break;
case -4:
SetErrMsg("wlt文件格式错误!");
break;
case -5:
SetErrMsg("软件未授权!");
break;
case -6:
SetErrMsg("设备连接失败!");
break;
case -8:
SetErrMsg("未能验证卡,请确认已经正确放置卡!");
break;
}
return false;
}
}
public static bool GetName(out byte[] NameBytes)
{
int iRet;
CleanErrMsg();
byte[] iRetBytes = new byte[30];
iRet = C_GTICR100.GetPeopleName(iRetBytes, 30);
if (iRet == 0)
{
SetErrMsg("读取姓名信息异常!");
NameBytes = null;
return false;
}
else
{
NameBytes = iRetBytes;
}
return true;
}
public static string GetName_Str()
{
string iRet = "";
byte[] iRetBytes;
if (GetName(out iRetBytes) == true)
{
Encoding iStrEncod = Encoding.GetEncoding("gb2312");
iRet = iStrEncod.GetString(iRetBytes);
}
return iRet;
}