So I have a function in vb that is converted to a dll that I want to use in python. However trying to use it, I get an error message
this is the VB function
Function DISPLAYNAME(Name)
MsgBox ("Hello " & Name & "!")
End Function
and this is how I call it in python
from ctypes import *
test = windll.TestDLL
print test
print test.DISPLAYNAME("one")
But I get errors so what is the right way of calling the dll
Traceback (most recent call last):
File "C:\Test\testdll.py", line 4, in
print test.DISPLAYNAME("one")
File "C:\Python26\lib\ctypes\__init__.py", line 366, in __getattr__
func = self.__getitem__(name)
File "C:\Python26\lib\ctypes\__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'DISPLAYNAME' not found
I have been looking around online but no solution so far. Can't use cdll since this is for c progs.
I have looked at some of the python and dll related questions but no solution so far works for my issue.
解决方案
It might be a scoping issue, with out the Public access modifier, the function may not be visible to external callers. Try
Public Function DISPLAYNAME(Name)
MsgBox ("Hello " & Name & "!")
End Function
in your dll
出处:https://blog.csdn.net/weixin_35726374/article/details/118794333?spm=1001.2101.3001.6650.8&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-8.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-8.pc_relevant_default&utm_relevant_index=17