注册 登录
编程论坛 Python论坛

python 调用动态链接库求助

zzkzfh 发布于 2010-03-08 16:14, 1227 次点击
C++ dll代码:
    extern "C" int __stdcall test();

    int __stdcall test()
    {
        return 1;
    }

python调用代码:
>>> from ctypes import*
>>> dll = CDLL("D:\\INetWork.dll")
>>> i = dll.test
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    i = dll.test
  File "C:\Python31\lib\ctypes\__init__.py", line 363, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python31\lib\ctypes\__init__.py", line 368, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'test' not found
>>>
接触python 2个星期了 想自己写程序实验下
总是找不到test函数是为什么?
我用的python版本是3.1
3 回复
#2
zzkzfh2010-03-08 16:25
没有人回答么?
#3
usertony2010-03-28 21:35
大哥,你的dll好像写的不对哦,动态链接库中的导出函数好像不是这样写的
#4
kenny_star2010-08-16 11:28
i = dll.test
方法调用时这样的吗,这不成了属性调用了吗?
1