When no parameters needs to be passed in, it all works, with the same dll. But when I have to pass int or char*, I get errors. I followed instructions on ctype documentation for Python. C/C++ code is as follows,
typedef int LNI;
#if !defined(RC_INCLUDE)
#if !defined(_DLLEXPORT_)
// If _DLLEXPORT_ is not defined then the default is to import.
#if defined(__cplusplus)
#define DLLENTRY extern "C" __declspec(dllimport)
#define STDENTRY extern "C" __declspec(dllimport) HRESULT WINAPI
#define STDENTRY_(type) extern "C" __declspec(dllimport) type WINAPI
#else
#define DLLENTRY __declspec(dllimport)
#define STDENTRY __declspec(dllimport) HRESULT WINAPI
#define STDENTRY_(type) __declspec(dllimport) type WINAPI
#endif
#else // _DLLEXPORT_
// Else if _DLLEXPORT_ is defined then we've been told to export.
#if defined(__cplusplus)
#define DLLENTRY extern "C" __declspec(dllexport)
#define STDENTRY extern "C" __declspec(dllexport) HRESULT WINAPI
#define STDENTRY_(type) extern "C" __declspec(dllexport) type WINAPI
#else
#define DLLENTRY __declspec(dllexport)
#define STDENTRY __declspec(dllexport) HRESULT WINAPI
#define STDENTRY_(type) __declspec(dllexport) type WINAPI
#endif
#endif // _DLLEXPORT_
// Here is the list of service APIs offered by the DLL (using the
// appropriate entry API declaration macros just #defined above).
STDENTRY_(LNI) ldv_open(char* device_name);
I am trying to access ldv_open using Python 2.7, but I am continue to get "ValueError: Procedure called with not enough arguments <4 byte missing> or wrong calling convention. I have Goggled this issue and tried every solution I found. Still no solution. Can someone please tell me what I am doing wrong here?
import ctypes
import string
lib = ctypes.CDLL('wldv32')
lib.ldv_open.argtypes = [ctypes.c_char_p]
lib.ldv_open.restype = ctypes.c_int
s = "Lonusb8"
ss = ctypes.c_char_p(s)
print s
print ss
lib.ldv_open(ss)
Aucun commentaire:
Enregistrer un commentaire