访问winscard.dll的python脚本

访问winscard.dll的python脚本,python,pointers,ctypes,loadlibrary,winscard,Python,Pointers,Ctypes,Loadlibrary,Winscard,大家好,我正在编写一个python脚本来访问windows的winscard.dll lib = cdll.LoadLibrary('winscard.dll') hSC = c_long(0) lRetval = lib.SCardEstablishContext(0,None,None,pointer(hSC)) 上面返回的值错误如下所示 Traceback (most recent call last): File "C:\Documents and Settings\sbritto

大家好,我正在编写一个python脚本来访问windows的winscard.dll

lib = cdll.LoadLibrary('winscard.dll')
hSC = c_long(0)
lRetval = lib.SCardEstablishContext(0,None,None,pointer(hSC))
上面返回的值错误如下所示

Traceback (most recent call last):
  File "C:\Documents and Settings\sbritto\Desktop\OpenSSL\python\test.py", 
  line 17, in <module>
    lRetval = lib.SCardEstablishContext(0,None,None,pointer(hSC))
ValueError: Procedure called with not enough arguments (16 bytes missing) or 
wrong calling convention
本例中的值错误表示参数错误。但我不知道还有什么可以作为输入使其工作,我尝试了几种输入组合


谢谢大家。

您对DLL使用了错误的调用约定:

lib = ctypes.WinDLL("winscard")
handle = ctypes.c_voidp()
lib.SCardEstablishConnection(0, None, None, ctypes.pointer(handle))
# returns 0, all is good
handle
# c_void_p(some address), handle got created

请确保智能卡服务已启动。否则你会得到一个神秘的错误代码。

我不知道这是什么原因。但也许对你有一些用处。希望对你有帮助。我非常希望看到这个工作。。。