Kaushil Rambhia
Kaushil Rambhia

Reputation: 195

Python dll function are not found

I have wrote code as below to communicate with a dll.i have registered this dll.

from ctypes import cdll
# give location of dll
mydll = cdll.LoadLibrary("C:\Windows\SysWOW64\zkemkeeper.dll")
ip = "172.16.16.70"
port = "4370"
mydll.Connect_Net(ip,port)    

I get the following error whenevr i execute it.

Traceback (most recent call last):
  File "C:\Python34\fetch.py", line 6, in <module>
    mydll.Connect_Net(ip,port)
  File "C:\Python34\lib\ctypes\__init__.py", line 364, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python34\lib\ctypes\__init__.py", line 369, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Connect_Net' not found      

Also i m able to communicate with this dll and access its function using PHP.Can anyone let me know what can be the issue and how to solve it.

Upvotes: 1

Views: 3310

Answers (2)

mike_z
mike_z

Reputation: 11

Try this Python snippet:

from win32com.client import Dispatch
zk = Dispatch("zkemkeeper.ZKEM")
ip = "172.16.16.70"
port = "4370"
zk.Connect_Net(IP_address, port)

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 612954

AttributeError: function 'Connect_Net' not found      

This means that the DLL does not export a function named 'Connect_Net'. Perhaps you got the name wrong, or the DLL failed to export the function somehow.

Some other comments:

  • Using the backslash escape character is running the gauntlet. Escape the backslash, use a raw string literal, or use os.path.join.
  • Don't modify the system directories. You should put your DLL elsewhere.

Upvotes: 0

Related Questions