vb.net - ACR122u help in reading the card -
private sub read(sender object, e eventargs) handles mybase.load dim readercount integer dim readercount integer dim ctr integer dim sreaderlist string dim ctr integer dim sreaderlist string ctr = 0 255 sreaderlist = sreaderlist + vbnullchar next readercount = 255 ' 1. establish context , obtain hcontext handle retcode = modwinscard.scardestablishcontext(modwinscard.scard_scope_user, 0, 0, hcontext) ' 2. list pc/sc card readers installed in system retcode = modwinscard.scardlistreaders(hcontext, "", sreaderlist, readercount) ' load available readers call loadlisttocontrol(cbreader, sreaderlist) cbreader.selectedindex = 0 if connactive retcode = modwinscard.scarddisconnect(hcard, modwinscard.scard_unpower_card) end if ' shared connection retcode = modwinscard.scardconnect(hcontext, cbreader.selecteditem.tostring(), modwinscard.scard_share_shared, modwinscard.scard_protocol_t0 or modwinscard.scard_protocol_t1, hcard, protocol) connactive = true connect() end sub public sub connect() dim tmpstr string dim indx integer validats = false call clearbuffers() sendbuff(0) = &hff ' cla sendbuff(1) = &hca ' ins sendbuff(3) = &h0 ' p2 sendbuff(4) = &h0 ' le : full length sendlen = sendbuff(4) + 5 recvlen = &hff retcode = sendapduanddisplay(3) if retcode <> modwinscard.scard_s_success exit sub end if indx = 0 (recvlen - 3) tmpstr = tmpstr + microsoft.visualbasic.right("00" & hex(recvbuff(indx)), 2) + " " next indx carduid = tmpstr attendace_menu.show() me.hide() end sub
i need code. want read uid of smart card not when loading form when remove card , insert again. reads card when load form. have no idea since i'm new programming , project school.
you can use winscard library's scardgetstatuschange function observe changes via background worker thread.
Comments
Post a Comment