【发布时间】:2009-07-06 17:02:09
【问题描述】:
myPythonClient(下)想要调用ringBell 函数(使用ctypes 从DLL 加载)。但是,尝试通过其name 访问ringBell 会导致AttributeError。为什么?
RingBell.h 包含
namespace MyNamespace
{
class MyClass
{
public:
static __declspec(dllexport) int ringBell ( void ) ;
} ;
}
RingBell.cpp 包含
#include <iostream>
#include "RingBell.h"
namespace MyNamespace
{
int __cdecl MyClass::ringBell ( void )
{
std::cout << "\a" ;
return 0 ;
}
}
myPythonClient.py 包含
from ctypes import *
cdll.RingBell[1]() # this invocation works fine
cdll.RingBell.ringBell() # however, this invocation errors out
# AttributeError: function 'ringBell' not found
【问题讨论】:
标签: python dll ctypes attributeerror