haochengqian / ZKTeco

Example of ZKTeco SDK with python
9 stars 7 forks source link

Error while instantiating class zk.zk() #1

Closed amrnegm closed 5 years ago

amrnegm commented 5 years ago

The following error is raised when instantiating class zk.zk()

Traceback (most recent call last): File "", line 1, in File "zk.py", line 9, in init self.zk = win32com.client.Dispatch('zkemkeeper.ZKEM.1') File "C:\Python27\lib\site-packages\win32com\client__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221005, 'COM Error 0x800401f3', None, None)

Steps to reproduce error:

haochengqian commented 5 years ago

This python package requires the ZTK COM service under the Windows operating system. I wrote this code two years ago and I forgot details of this module. So I just could give you some advice. Maybe you could try to look into the dynamic library file by some tools and find the right function name and function parameter instead of just looking at the document. The document maybe too old for ZTK COM service now.

amrnegm commented 5 years ago

I registered libs on windows by copying them to C:\windows\system32 then running the 64bit_register_sdk bat file, and this error disappeared. It is now able to load zkemkeeper lib. However, another error showed up Member not found when your zk class try to instantiate an object from zkemkeeper.ZKEM.

I used combrowse dll browser from pywin32 to browse lib. I am not sure I understand the displayed structure, but it looks like it contains the methods demonstrated in documentation. If you can explain it to me, I can share a screenshot of the library structure generated from combrowse. The blocking issue now is to have an instance from zkemkeeper.ZKEM class, then use its internal methods.

I saw that you instantiate object from zkemkeeper.ZKEM.1. What does this number mean?

Also, I have .Net code that uses the library but instantiates from zkemkeeper.CZKEM class. The code is working. And it calls the same methods that you are calling when you instantiate from zkemkeeper.ZKEM.1. Is there an explanation for the difference in class names used in each case? Unfortunately, I have no background is dealing with dlls or Microsoft development stack in general, that is why my questions may look naive.

amrnegm commented 5 years ago

I have made a try that seemed to work. I ran win32com.client.CastTo('zkemkeeper.ZKEM', 'IZKEM'), it returned an object that I can call upon, for example, Connect_Net that establishes a connection with machine.