cByte[0]=0x1b;
cByte[1]=0x72;//114
cByte[2]=0x73;
cByte[3]=0x01;//注意长度为两个数
cByte[4]=0x21;//289//92//0121
cByte[5]=0x89;
cByte[6]=0x02;
all[0]+=cByte[3]+cByte[4]+cByte[5]+cByte[6];//加四个,因为长度0X01容易被忽略
////////////////第一个指纹不需要校验和
for(int i=0 ,j=7;j<150;i=i+2,j++)//i为字符串第几个截取的INDEX,j为第几个特征,最后一个是检验和
{//572
temp=s.Mid(i,2);
cByte[j]=CStringTo16byte(temp);
all[0]+=cByte[j];
}
////////////////
for(int i1=286, j1=150;j1<293;i1=i1+2,j1++)//i为字符串第几个截取的INDEX,j为第几个特征,最后一个是检验和
{
temp=s.Mid(i1,2);
cByte[j1]=CStringTo16byte(temp);
all[0]+=cByte[j1];
}
cByte[293]=all[0];
////////////////
DWORD dwWriteCount = 0;
DWORD dwReadCount = 0;
DWORD dwCommStatus;
SetCommMask (handle, EV_TXEMPTY);
if(handle!=NULL)
WriteFile(handle,cByte,294, &dwWriteCount, 0);
WaitCommEvent( handle, &dwCommStatus, NULL );
if((dwCommStatus & EV_TXEMPTY) == EV_TXEMPTY)//
{
ReadFile(handle,cGetByte, 8, &dwReadCount, NULL);
str.Format(_T("%02x %02x %02x %02x %02x %02x %02x %02x") , cGetByte[0] , cGetByte[1] ,
cGetByte[2] , cGetByte[3] , cGetByte[4] , cGetByte[5] , cGetByte[6] , cGetByte[7]);
}
while(true)
{
if(str == CString("1b 72 73 00 03 89 00 8c"))
{
MessageBox(NULL,"您已通过验证.","指纹验证",NULL);
break;
}
if(str == CString("1b 72 73 00 03 89 32 be"))
{
MessageBox(NULL,"请用登记过的手指验证.","验证失败",MB_ICONHAND);
break;
}
评论