Created
January 27, 2014 03:47
-
-
Save tpdn/8642985 to your computer and use it in GitHub Desktop.
winscard sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import winscard | |
from ctypes import * | |
import time | |
import sys | |
user32 = windll.user32 | |
sc = winscard.SCard() | |
reader = sc.list_readers()[0] | |
while(True): | |
while(True): | |
try: | |
reader.connect() | |
c = False | |
break | |
except winscard.WinSCardError as e: | |
if e.errno == winscard.SCARD_W_REMOVED_CARD: | |
time.sleep(0.1) | |
else: | |
print e | |
sys.exit(1) | |
cardid = reader.transmit((0xFF, 0xCA, 0x00, 0x00, 0x00), winscard.SCARD_PCI_T1) | |
reader.disconnect() | |
print [hex(x) for x in cardid] | |
txt = "".join([str.format('{0:02X}',x) for x in cardid]) | |
user32.MessageBoxA( | |
0, | |
txt, | |
"your card id", | |
0x00000040) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment