Python: Zugriff auf DLL-Funktion mit ctypes - Zugriff über Funktion * Name * schlägt fehl
myPythonClient
(unten) möchte a aufrufenringBell
Funktion (geladen von einer DLL mitctypes
). Es wird jedoch versucht, darauf zuzugreifenringBell
über seineName führt zu einerAttributeError
. Warum?
RingBell.h
enthält
namespace MyNamespace
{
class MyClass
{
public:
static __declspec(dllexport) int ringBell ( void ) ;
} ;
}
RingBell.cpp
enthält
#include <iostream>
#include "RingBell.h"
namespace MyNamespace
{
int __cdecl MyClass::ringBell ( void )
{
std::cout << "\a" ;
return 0 ;
}
}
myPythonClient.py
enthält
from ctypes import *
cdll.RingBell[1]() # this invocation works fine
cdll.RingBell.ringBell() # however, this invocation errors out
# AttributeError: function 'ringBell' not found