Ctype, C++ and CPython zusammen.
Verfasst: Donnerstag 28. März 2013, 22:00
Hye,
ich steh zur Zeit wie ein Ochs vorm Berg und versuche eigntlich, was ganz einfaches zu machen. Ich habe eine Dll in C++ und will die Functions einfach nur in Python 2.7 aufrufen. Mein ertser Ansatz war :
import os
dirlist = os.listdir('ForexConnectAPIx64/bin')
from pprint import pprint
pprint(dirlist)
from ctypes import *
myDll = cdll.LoadLibrary ("ForexConnectAPIx64/bin/ForexConnect.dll")
und das Ergebnis ist :
traceback (most recent call File "C:\Users\scaberia3\Python_Projects \FTC\ListDir_Test.py", line 20, in <module>
myDll = cdll.LoadLibrary ("ForexConnectAPIx64/bin/ForexConnect.dll")
File "C:\Python33\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python33\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Das angegebene Modul wurde nicht gefunden (Module not found)
['ForexConnect.dll',
'fxmsg.dll',
'gsexpat.dll',
'gslibeay32.dll',
'gsssleay32.dll',
'gstool2.dll',
'gszlib.dll',
'java',
'log4cplus.dll',
'msvcp80.dll',
'msvcr80.dll',
'net',
'pdas.dll']
Dependency Walker hat mir gezeigt, es gitb noch mehr dlls in ForexConnect.dll, also habe ich den PythonPfad geaendert :
dllpath = os.path.abspath('ForexConnectAPIx64/bin')
os.environ['PATH'] += os.pathsep + dllpath
myDLL = CDLL('ForexConnect.dll')
Jetzt gibt es zwar keine Fehlermeldung mehr, aber ein dir(myDLL) ergibt auch nichts.
Print type(mydll) zeigt <class 'ctypes.CDLL'>.
Was mache ich falsch oder wie kann ich die Classes aufrufen ?
Schonmal vielen Dank fuer Eure Hilfe.
Adrian
ich steh zur Zeit wie ein Ochs vorm Berg und versuche eigntlich, was ganz einfaches zu machen. Ich habe eine Dll in C++ und will die Functions einfach nur in Python 2.7 aufrufen. Mein ertser Ansatz war :
import os
dirlist = os.listdir('ForexConnectAPIx64/bin')
from pprint import pprint
pprint(dirlist)
from ctypes import *
myDll = cdll.LoadLibrary ("ForexConnectAPIx64/bin/ForexConnect.dll")
und das Ergebnis ist :
traceback (most recent call File "C:\Users\scaberia3\Python_Projects \FTC\ListDir_Test.py", line 20, in <module>
myDll = cdll.LoadLibrary ("ForexConnectAPIx64/bin/ForexConnect.dll")
File "C:\Python33\lib\ctypes\__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "C:\Python33\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Das angegebene Modul wurde nicht gefunden (Module not found)
['ForexConnect.dll',
'fxmsg.dll',
'gsexpat.dll',
'gslibeay32.dll',
'gsssleay32.dll',
'gstool2.dll',
'gszlib.dll',
'java',
'log4cplus.dll',
'msvcp80.dll',
'msvcr80.dll',
'net',
'pdas.dll']
Dependency Walker hat mir gezeigt, es gitb noch mehr dlls in ForexConnect.dll, also habe ich den PythonPfad geaendert :
dllpath = os.path.abspath('ForexConnectAPIx64/bin')
os.environ['PATH'] += os.pathsep + dllpath
myDLL = CDLL('ForexConnect.dll')
Jetzt gibt es zwar keine Fehlermeldung mehr, aber ein dir(myDLL) ergibt auch nichts.
Print type(mydll) zeigt <class 'ctypes.CDLL'>.
Was mache ich falsch oder wie kann ich die Classes aufrufen ?
Schonmal vielen Dank fuer Eure Hilfe.
Adrian