USB讀(dú)卡器windows JNI開發(fā)例程
摘要
USB讀(dú)卡器windows JNI開發(fā)例程
windows在java中使用JNI調(diào)用usb讀卡器的動(dòng)态庫yw60x.dll

public static void main(String[] args)
{ int ReaderID=1; int Requestmode=38; short Cardtype[]=new short[1]; byte LenSn[] = new byte[1]; byte CardNo[] = new byte[8]; byte Key[]=new byte[]{(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}; byte BlockData[]=new byte[16]; YOWORFID rfidreader = new YOWORFID(); rfidreader.YW_USBHIDInitial(); int rt =0; { rt =rfidreader.YW_RequestCard(ReaderID,Requestmode,Cardtype); //if(rt<=0)continue; rt = rfidreader.YW_AntiCollide(ReaderID,LenSn,CardNo); HexToStr(CardNo,LenSn[0]); rt =rfidreader.YW_CardSelect(ReaderID,LenSn[0],CardNo); rt =rfidreader.YW_KeyAuthorization(ReaderID,96,4,Key); System.out.printf("KeyAuthorization=%d",rt);System.out.println(); rt =rfidreader.YW_ReadaBlock(ReaderID,4,16,BlockData); System.out.printf("YW_ReadaBlock=%d",rt);System.out.println(); if(rt>0){HexToStr(BlockData,16);} } rfidreader.YW_Led(ReaderID,1,1,1,3,0); rfidreader.YW_USBHIDFree();
}
}

